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

Gradio Web Demo #25

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Gradio Web Demo #25

wants to merge 19 commits into from

Conversation

AK391
Copy link

@AK391 AK391 commented Jun 25, 2021

easy to use web demo on gradio hub

@google-cla google-cla bot added the cla: yes SignCLA enabled label Jun 25, 2021
gradio/demo.py Outdated

url2 = 'https://cdn.pixabay.com/photo/2014/05/20/21/20/bird-349026_1280.jpg'
r = requests.get(url2, allow_redirects=True)
open("bird.jpg", 'wb').write(r.content)
Copy link
Collaborator

Choose a reason for hiding this comment

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

for some reason this image fails at inference (it shows "error") on the top right corner of output.

Copy link
Collaborator

Choose a reason for hiding this comment

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

btw any chance we can inspect the error message? that would help debugging

Copy link
Author

Choose a reason for hiding this comment

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

errors are shown in logs here https://gradio.app/glogs/AK391/deeplab2 as for the error it could be related to oom?

Copy link
Collaborator

Choose a reason for hiding this comment

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

cool! maybe add this pointer somewhere so anyone who encountered issues might be able to check this?

gradio/demo.py Outdated

url1 = 'https://cdn.pixabay.com/photo/2021/01/28/18/21/beach-5958718_1280.jpg'
r = requests.get(url1, allow_redirects=True)
open("town.jpg", 'wb').write(r.content)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Our models are trained on cityscapes, it might not generalize well on other images tho. Could we use similar images?

Copy link
Author

Choose a reason for hiding this comment

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

sure ill change this to something similar

Copy link
Author

Choose a reason for hiding this comment

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

changed to similar images

Copy link
Contributor

Choose a reason for hiding this comment

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

For those demo images, is there any licence issue?
Are they free to use?

gradio/demo.py Outdated
plt.xticks([], [])
ax.tick_params(width=0.0, grid_linewidth=0.0)
plt.grid('off')
# plt.show()
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove instead of comment out?

Copy link
Author

Choose a reason for hiding this comment

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

yes i will remove it

Copy link
Author

Choose a reason for hiding this comment

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

comment removed

gradio/demo.py Outdated
except KeyboardInterrupt:
print("Process interrupted")
sys.exit(1)
MODEL_NAME = 'max_deeplab_l_backbone_os16_axial_deeplab_cityscapes_trainfine_saved_model'
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it be possible for users to select which model to use?

btw the default model here (maxdeeplab l) is fairly heavy. Would a lighterweight model be better as default? (e.g resnet50_os32_panoptic_deeplab_cityscapes_crowd_trainfine_saved_model)

Copy link
Author

Choose a reason for hiding this comment

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

Hi sure i can try that currently using cpu on gradio hub so that is why inference is slow, I will update with this one to see if that helps

Copy link
Author

Choose a reason for hiding this comment

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

that is alot faster thanks!
Screen Shot 2021-06-28 at 7 34 02 PM

Copy link
Author

Choose a reason for hiding this comment

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

in terms of the user choosing the model, I think lightweight models would be better for user experience, so I can create a dropdown that only include the lightweight ones

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes a dropdown would be great. optionally we can also include larger ones and note users that could take a long time.

gr.Interface(
inference,
[gr.inputs.Image(type="pil", label="Input")],
gr.outputs.Image(type="plot", label="Output"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

haven't used gradio yet, would it be possible to output multiple plots instead one? for now the output plots (input / segmentation / overlay / legend) are very small to inspect

Copy link
Author

Choose a reason for hiding this comment

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

yes multiple plots are possible, I tried to folllow the colab notebook as how the plots were presented there

Copy link
Author

Choose a reason for hiding this comment

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

also the image is downloadable and can be opened then to read easier

Copy link
Collaborator

Choose a reason for hiding this comment

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

y download images would be good. just thinking having separate plots would look better on the webui (and we dont need to show the original image again). Colab shows everything in one window just due to we dont want to execute extra code blocks to show them :)

Copy link
Author

Choose a reason for hiding this comment

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

ok sounds good, also could the colab be updated to not show the input image as well I think the layout would show the legend on the side the two plots side by side


url2 = 'https://cdn.pixabay.com/photo/2016/02/19/11/36/canal-1209808_1280.jpg'
r = requests.get(url2, allow_redirects=True)
open("city2.jpg", 'wb').write(r.content)
Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry for a late comment on style here: would it be possible to move these variables into main() and add a section

if name == 'main':
app.run(main)

This would be more consistent with other python scripts in this repo.

Copy link
Author

Choose a reason for hiding this comment

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

is this the right section of code for this comment?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was referring to line 19-25 here. variables url1 / r / url2 are global variables and might hurt readability.

deeplab2 codebase encourage removing global variables if possible, with the exception of global constants (where the variable naming would be all caps)

gradio/demo.py Outdated

url1 = 'https://cdn.pixabay.com/photo/2021/01/28/18/21/beach-5958718_1280.jpg'
r = requests.get(url1, allow_redirects=True)
open("town.jpg", 'wb').write(r.content)
Copy link
Contributor

Choose a reason for hiding this comment

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

For those demo images, is there any licence issue?
Are they free to use?

@@ -0,0 +1,5 @@
matplotlib
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please not include requirements.txt for the PR?
We deleted them on purpose so that users will not just install sth wrong via pip install -r requirements.txt

@@ -43,6 +43,11 @@ We list a few projects that use DeepLab2.

* <a href='https://colab.research.google.com/github/google-research/deeplab2/blob/main/DeepLab_Demo.ipynb'>Colab notebook for off-the-shelf inference.</a><br>

## Gradio Demo

* <a href='https://gradio.app/hub/AK391/deeplab2'>Gradio Web Demo</a><br>

Choose a reason for hiding this comment

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

I am getting error 502 Bad Gateway with this URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes SignCLA enabled
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants