user-agent commited on
Commit
d4a7da4
·
verified ·
1 Parent(s): 71a0135

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -13
app.py CHANGED
@@ -56,32 +56,21 @@ def gradio_predict(url, threshold):
56
  tags, error = predict_tags(url, threshold)
57
  if error:
58
  return error, None
59
- # Return tags, and the image as a PIL object
60
  image = load_image_from_url(url)
61
  return "\n".join([f"{tag}: {score:.2f}" for tag, score in tags]), image
62
 
63
-
64
  demo = gr.Interface(
65
  fn=gradio_predict,
66
  inputs=[
67
- gr.Textbox(label="Image URL", value="https://d2q1sfov6ca7my.cloudfront.net/eyJidWNrZXQiOiJoaWNjdXAtaW1hZ2UtaG9zdGluZyIsImtleSI6ImhpY2N1cC1wcm9kdWN0cy9GQVFZTFkyNzFGLmpwZWciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjI1NjAsImhlaWdodCI6Mzg0MCwiZml0IjoiY292ZXIifX19?v=1748968367"),
68
  gr.Slider(0, 1, value=0.5, step=0.01, label="Threshold"),
69
  ],
70
  outputs=[
71
  gr.Textbox(label="Tags"),
72
- gr.Image(label="Preview", type="url"),
73
  ],
74
  title="Image Tagging with ViT",
75
  description="Paste an image URL and get predicted tags using thelabel/240903-image-tagging model.",
76
- examples=[
77
- [
78
- "https://d2q1sfov6ca7my.cloudfront.net/eyJidWNrZXQiOiJoaWNjdXAtaW1hZ2UtaG9zdGluZyIsImtleSI6ImhpY2N1cC1wcm9kdWN0cy9GQVFZTFkyNzFGLmpwZWciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjI1NjAsImhlaWdodCI6Mzg0MCwiZml0IjoiY292ZXIifX19?v=1748968367", 0.5
79
- ],
80
- [
81
- "https://d2q1sfov6ca7my.cloudfront.net/eyJidWNrZXQiOiJoaWNjdXAtaW1hZ2UtaG9zdGluZyIsImtleSI6ImhpY2N1cC1wcm9kdWN0cy9ON01aQkpUMDlFLmpwZWciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjI1NjAsImhlaWdodCI6Mzg0MCwiZml0IjoiY292ZXIifX19?v=1748968367", 0.5
82
- ]
83
- ]
84
  )
85
-
86
  if __name__ == "__main__":
87
  demo.launch()
 
56
  tags, error = predict_tags(url, threshold)
57
  if error:
58
  return error, None
 
59
  image = load_image_from_url(url)
60
  return "\n".join([f"{tag}: {score:.2f}" for tag, score in tags]), image
61
 
 
62
  demo = gr.Interface(
63
  fn=gradio_predict,
64
  inputs=[
65
+ gr.Textbox(label="Image URL"),
66
  gr.Slider(0, 1, value=0.5, step=0.01, label="Threshold"),
67
  ],
68
  outputs=[
69
  gr.Textbox(label="Tags"),
70
+ gr.Image(label="Preview", type="pil"),
71
  ],
72
  title="Image Tagging with ViT",
73
  description="Paste an image URL and get predicted tags using thelabel/240903-image-tagging model.",
 
 
 
 
 
 
 
 
74
  )
 
75
  if __name__ == "__main__":
76
  demo.launch()