-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PR] Fixing reconnection error and adding image list #17
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 32 54 +22
=========================================
+ Hits 32 54 +22 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my late response, I am out. Yes of course feel free to modify this if you are happy with this. I wasn't sure it was in line with what you really expected. The HTML is really bad 😥 and the Readme needs to be modified as well. Was just a draft for you to see. I added tests because I wanted to learn this from your code, and the "receive" trick is nice!. I also didn't use the BLIP because the other model is simply faster for dev, so the model handling is not up-to-date, nor deployable with all the modifications you made. You could also use random images from unsplash and have the joy to discover new images every time as well as the descriptions. This is a real good test and is more fun. #page_live.ex, lines 5-7
@unsplashes [
"https://source.unsplash.com/random/300x300",
"https://source.unsplash.com/random/310x310"
] I also thought that instead of a delayed display of examples, you could add a click button "Show me examples" beneath to show the examples as a component: instead of a Lastly, I have another branch that can be seen as a "nice" extension I upload to S3, save the response URL in an SQLite db once the caption job is done. The idea is to implement a speech-to-text and a full-text-search (usper easy in SQLite since FS5 is already embedded) to find images from the DB whose caption contains some tags. A simple an input as text of a tag/keyword can run a direct full-text-search in the caption field. You may want to improve this and play with the ML capabilities of Bumblebee: you add a speech-to-text (a Javacsript hook to enable the microphone and save the audio into a blob, and |
@ndrean you have if you can push your branch directly to the remote: |
# Conflicts: # .gitignore # lib/app/application.ex # lib/app_web/live/page_live.ex # mix.lock
@LuchoTurtle thanks for picking this up to enhance and test. 🙏 Ping me if you need anything from me or when you want a review. 👌 |
…they are rendered correctly.
… to show examples.
Should be reviewable 👌 |
Of course I don't mind! I'm learning the most with your feedback! You're completely right, I should have reused the the URL instead of base64 encoding the images, it's utterly unnecessary. It went right over my head, thanks you. And it's okay! Your PR laid the groundwork for the PR, it helped a ton! |
To get the URL, it is a matter of merging the URL into the (Image-To-Text) task map, after you upload the image with |
And I am the one who learns with your tests! |
Yeah, I understand. I remember why I was base64 encoding the images. It's because the |
Can't this fix it? tasks = for _ <- 1..2 do
{:req, body} = {:req, Req.get!(random_image).body}
predict_example_image(random_image, body)
^^^
end
[...]
def predict_example_image(rand_url, body) do
^^^
with {:vix, {:ok, img_thumb}} <-
{:vix, Vix.Vips.Operation.thumbnail_buffer(body, @image_width)},
{:pre_process, {:ok, t_img}} <- {:pre_process, pre_process_image(img_thumb)} do
# Create an async task to classify the image from unsplash
Task.Supervisor.async(App.TaskSupervisor, fn ->
Nx.Serving.batched_run(ImageClassifier, t_img)
end)
|> Map.merge(%{url: rand_url})
^^^
else
{stage, error} -> {stage, error}
end
end
|
It doesn't because the I need to find a way to get the URL after ^ These are the links I need. I need to follow the redirection, but |
oh I see. def rand_splash do
%{scheme: scheme, host: host, path: path} =
Finch.build(:get, "https://source.unsplash.com/random/")
|> Finch.request!(MyFinch)
|> Map.get(:headers)
|> Enum.filter(fn {a, _b} -> a == "location" end)
|> List.first()
|> elem(1)
|> URI.parse()
scheme <> "://" <> host <> path
end App.rand_splash()
# https://images.unsplash.com/photo-1694813646634-9558dc7960e3
App.rand_splash()
# https://plus.unsplash.com/premium_photo-1698846878442-4f0b4166fb85 |
Thanks for the function. I've added it to the README. Thanks for the feedback 👌 |
Only use Finch and remove Req, no? |
let inactivityTimer; | ||
let processHasBeenSent = false; | ||
|
||
let ctx = this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say I understand the need to set ctx = this
variable ... 🤷♂️
Please consider leaving a clarifying comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having trouble sending the pushEvent
otherwise. The this
inside the resetInactivityTimer
function yielded undefined
when I tried pushing the event every time. So I had to get the this
from the mounted
function instead.
I'll add a clarifying comment in the next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the context isn't inferred from the parent function, sadly. Comment very much appreciated. Thanks. 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The joy of this
in context with JS. Take a look at my draft code for Speech-To-Text "Audio" hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ndrean & @LuchoTurtle this looks good. 🙌
Happy to merge.
Ah, good! You made it with If you really want to showcase def get_redirected_url do
Finch.build(:get, @url)
|> Finch.request!(MyFinch)
|> Map.get(:headers)
|> Enum.filter(fn {a, _b} -> a == "location" end)
|> List.first()
|> elem(1)
The rest of the code was here to extract the path without the query string. |
closes #11
closes #7