Skip to content
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] Creating basic image classifier with Elixir #2

Merged
merged 30 commits into from
Nov 13, 2023
Merged

[PR] Creating basic image classifier with Elixir #2

merged 30 commits into from
Nov 13, 2023

Conversation

LuchoTurtle
Copy link
Member

closes #1

This creates a simple image classifier with Bumblebee and performs image captioning tasks that return a descriptive text of the image (not to be confused with image classification, which yields a weighted list of predictions).

@LuchoTurtle LuchoTurtle added documentation Improvements or additions to documentation enhancement New feature or enhancement of existing functionality in-progress An issue or pull request that is being worked on by the assigned person labels Oct 30, 2023
@LuchoTurtle LuchoTurtle self-assigned this Oct 30, 2023
@LuchoTurtle
Copy link
Member Author

I'm having immense trouble previewing the image and copying it to the DOM before consuming it.
In order to actually use the image to classify it, I need to consume it. However, this effectively removes the image entry from the temporary folder and I lose access to it to show to the person.

I've tried using the image_live_preview function but it only works if the entry is not consumed, which is not possible in our scenario.

I'm trying to circumvent this by using an additional <input>, copying the file contents and displaying it in the DOM. But this, for some odd reason, makes it so that handle_progress/3 is not called, which in turn doesn't consume the entry.

allow_upload(:image_list,
       accept: ~w(image/*),
       auto_upload: true,
       progress: &handle_progress/3,
       max_entries: 1,
       chunk_size: 4_000,
       max_file_size: 64_000
     )}

I've tried many ways of doing this but I can't seem to figure it out. I could copy the file path to an upload directory, but that would mean that I'd need to manage all of the uploaded images, their correct deletion (even if the person crashes the LiveView), which is something I really don't want to "waste" time on.

@nelsonic

This comment was marked as outdated.

@LuchoTurtle
Copy link
Member Author

I've added virtually all of the documentation and the application is now functional.
I'm just having some trouble with having the tests covering 100% of the application. Because I'm using Task.async, I could technically add a sleep method for it to wait for the model to predict a given image. However, I feel like that's a "hack"/dirty copout.

I've been researching on how to get this to work, namely form:

But haven't had good results on this.

I'm trying to implement a supervisor to do this (from https://elixirforum.com/t/best-way-of-doing-an-integration-test-that-spans-a-task-start/39429/2) but I'm struggling to get it to work.

Other than that, the app works (although it does not show the image after submitting, which is something I wanted to get to work as well, but it's not "essential")

Copy link

codecov bot commented Nov 7, 2023

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

@LuchoTurtle LuchoTurtle removed their assignment Nov 7, 2023
@LuchoTurtle
Copy link
Member Author

This should be mergeable 👌

@LuchoTurtle LuchoTurtle marked this pull request as ready for review November 7, 2023 21:22
@LuchoTurtle LuchoTurtle assigned LuchoTurtle and unassigned nelsonic Nov 8, 2023
@LuchoTurtle LuchoTurtle added in-progress An issue or pull request that is being worked on by the assigned person and removed awaiting-review An issue or pull request that needs to be reviewed labels Nov 8, 2023
@nelsonic nelsonic mentioned this pull request Nov 8, 2023
5 tasks
@nelsonic
Copy link
Member

nelsonic commented Nov 8, 2023

@LuchoTurtle demo on Standup this morning was superb! 😍
PR is still assigned to you. Happy to review it later today. 👌
Meanwhile there are a couple of tasks you can crack on with: #3 & #4 😉

@LuchoTurtle
Copy link
Member Author

I've reassigned it to myself because I want to make some additional changes. I'll hand it over to you after those.

@nelsonic

This comment was marked as resolved.

@LuchoTurtle LuchoTurtle added awaiting-review An issue or pull request that needs to be reviewed and removed in-progress An issue or pull request that is being worked on by the assigned person labels Nov 8, 2023
@LuchoTurtle LuchoTurtle assigned nelsonic and unassigned LuchoTurtle Nov 8, 2023
@LuchoTurtle
Copy link
Member Author

Reassigning back to you 👌

@nelsonic
Copy link
Member

Gonna pick this up (run + review) as soon as I get a decent chunk of alone time.... 🤞 ⏳

Copy link
Member

@nelsonic nelsonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work @LuchoTurtle! 🥇
Merging so other people can learn along. 👌

@nelsonic nelsonic merged commit 888ddaf into main Nov 13, 2023
3 checks passed
@nelsonic nelsonic deleted the initial branch November 13, 2023 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review An issue or pull request that needs to be reviewed documentation Improvements or additions to documentation enhancement New feature or enhancement of existing functionality
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

Epic: Image Classifier
2 participants