Leigh Jewell commited on
Commit
46d2534
1 Parent(s): 5bb7068

Show image file in the result from the URL

Browse files
Files changed (2) hide show
  1. URL.txt +4 -0
  2. app.py +4 -4
URL.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Red jumper
2
+ https://assets.digitalcontent.marksandspencer.app/images/w_1024,q_auto,f_auto/SD_01_T38_1842T_B4_X_EC_90/Sparkly-Crew-Neck-Relaxed-Jumper
3
+ # Red trousers
4
+ https://www.crewclothing.co.uk/images/products/large/BEC101_POPPYRED.jpg
app.py CHANGED
@@ -5,7 +5,7 @@ import requests
5
  from PIL import Image
6
  from io import BytesIO
7
 
8
- fashion_items = ['top', 'trousers', 'jumper']
9
 
10
  # Load model and processor
11
  model_name = 'Marqo/marqo-fashionSigLIP'
@@ -44,16 +44,16 @@ def predict_from_url(url):
44
  image_features = image_features / image_features.norm(dim=-1, keepdim=True)
45
  text_probs = (100 * image_features @ text_features.T).softmax(dim=-1)
46
 
47
- return {fashion_items[i]: float(text_probs[0, i]) for i in range(len(fashion_items))}
48
 
49
 
50
  # Gradio interface
51
  demo = gr.Interface(
52
  fn=predict_from_url,
53
  inputs=gr.Textbox(label="Enter Image URL"),
54
- outputs=gr.Label(label="Classification Results"),
55
  title="Fashion Item Classifier",
56
- allow_flagging="never"
57
  )
58
 
59
  # Launch the interface
 
5
  from PIL import Image
6
  from io import BytesIO
7
 
8
+ fashion_items = ['top', 'trousers', 'jumper', "shirt", "shorts"]
9
 
10
  # Load model and processor
11
  model_name = 'Marqo/marqo-fashionSigLIP'
 
44
  image_features = image_features / image_features.norm(dim=-1, keepdim=True)
45
  text_probs = (100 * image_features @ text_features.T).softmax(dim=-1)
46
 
47
+ return {fashion_items[i]: float(text_probs[0, i]) for i in range(len(fashion_items))}, url
48
 
49
 
50
  # Gradio interface
51
  demo = gr.Interface(
52
  fn=predict_from_url,
53
  inputs=gr.Textbox(label="Enter Image URL"),
54
+ outputs=[gr.Label(label="Classification Results"), "image"],
55
  title="Fashion Item Classifier",
56
+ flagging_mode="never"
57
  )
58
 
59
  # Launch the interface