Skip to content

Commit

Permalink
remove some debugging stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
benswift committed Nov 1, 2024
1 parent 397cc2c commit 5246987
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 0 additions & 2 deletions lib/imaginative_restoration/ai/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ defmodule ImaginativeRestoration.AI.Utils do

mean = Enum.sum(diffs) / length(diffs)

dbg({diffs, mean})

# the docs say "In general, a hamming distance of less than 10 indicates that the images are very similar."
mean >= 10
end
Expand Down
25 changes: 12 additions & 13 deletions lib/imaginative_restoration_web/live/index_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,20 @@ defmodule ImaginativeRestorationWeb.IndexLive do
def handle_event("webcam_frame", %{"frame" => dataurl}, socket) do
pid = self()

if not Utils.changed_recently?(5) do
Logger.info("Skipping frame processing")
# only run the AI pipeline if stuff has changed recently
if Utils.changed_recently?(5) do
# spawn the task which will communicate back to self() via :update_sketch messages
Task.start(fn ->
dataurl
|> ImaginativeRestoration.Sketches.init!()
|> send_update_sketch_message(pid)
|> ImaginativeRestoration.Sketches.crop_and_set_prompt!()
|> send_update_sketch_message(pid)
|> ImaginativeRestoration.Sketches.process!()
|> send_update_sketch_message(pid)
end)
end

# spawn the task which will communicate back to self() via :update_sketch messages
Task.start(fn ->
dataurl
|> ImaginativeRestoration.Sketches.init!()
|> send_update_sketch_message(pid)
|> ImaginativeRestoration.Sketches.crop_and_set_prompt!()
|> send_update_sketch_message(pid)
|> ImaginativeRestoration.Sketches.process!()
|> send_update_sketch_message(pid)
end)

{:noreply, socket}
end

Expand Down

0 comments on commit 5246987

Please sign in to comment.