vincentb25 commited on
Commit
c24e460
·
1 Parent(s): 57f6ea3

Added examples and cleaned requierments

Browse files
app.py CHANGED
@@ -112,25 +112,22 @@ def inference(query, class1_name="class1", support_imgs=None, class2_name="class
112
  title = "P>M>F few-shot learning pipeline"
113
  description = "Short description: We take a ViT-small backbone, which is pre-trained with DINO, and meta-trained on Meta-Dataset; for few-shot classification, we use a ProtoNet classifier. The demo can be viewed as zero-shot since the support set is built by searching images from Google. Note that you may need to play with GIS parameters to get good support examples. Besides, GIS is not very stable as search requests may fail for many reasons (e.g., number of requests reaches the limit of the day). This code is heavely inspired from the original HF space <a href='https://huggingface.co/spaces/hushell/pmf_with_gis' target='_blank'>here</a>"
114
  article = "<p style='text-align: center'><a href='http://arxiv.org/abs/2204.07305' target='_blank'>Arxiv</a></p>"
115
-
116
-
117
  gr.Interface(fn=inference,
118
  inputs=[
119
  gr.Image(label="Image to classify", type="pil"),
120
- #gr.Textbox(lines=1, label="Class hypotheses:", placeholder="Enter class names separated by ','",),
121
-
122
  gr.Textbox(lines=1, label="First class name :", placeholder="Enter first class name",),
123
- gr.File(label="Drag or select one or more photos of the first class", file_types=["image"], file_count="multiple"),
124
-
125
  gr.Textbox(lines=1, label="Second class name :", placeholder="Enter second class name",),
126
- gr.File(label="Drag or select one or more photos of the second class", file_types=["image"], file_count="multiple"),
127
  ],
128
  theme="grass",
129
  outputs=[
130
  gr.Label(label="Predicted class probabilities"),
131
- #gr.Image(type='pil', label="Support examples from Google image search"),
132
  ],
133
  title=title,
134
  description=description,
135
  article=article,
 
 
 
136
  ).launch(debug=True)
 
112
  title = "P>M>F few-shot learning pipeline"
113
  description = "Short description: We take a ViT-small backbone, which is pre-trained with DINO, and meta-trained on Meta-Dataset; for few-shot classification, we use a ProtoNet classifier. The demo can be viewed as zero-shot since the support set is built by searching images from Google. Note that you may need to play with GIS parameters to get good support examples. Besides, GIS is not very stable as search requests may fail for many reasons (e.g., number of requests reaches the limit of the day). This code is heavely inspired from the original HF space <a href='https://huggingface.co/spaces/hushell/pmf_with_gis' target='_blank'>here</a>"
114
  article = "<p style='text-align: center'><a href='http://arxiv.org/abs/2204.07305' target='_blank'>Arxiv</a></p>"
 
 
115
  gr.Interface(fn=inference,
116
  inputs=[
117
  gr.Image(label="Image to classify", type="pil"),
 
 
118
  gr.Textbox(lines=1, label="First class name :", placeholder="Enter first class name",),
119
+ gr.File(label="First class example images", file_types=["image"], file_count="multiple"),
 
120
  gr.Textbox(lines=1, label="Second class name :", placeholder="Enter second class name",),
121
+ gr.File(label="Second class example iamges", file_types=["image"], file_count="multiple"),
122
  ],
123
  theme="grass",
124
  outputs=[
125
  gr.Label(label="Predicted class probabilities"),
 
126
  ],
127
  title=title,
128
  description=description,
129
  article=article,
130
+ examples=[
131
+ ["./example_images/2007_000033.jpg", "plane", ["./example_images/2007_000738.jpg", "./example_images/2007_000256.jpg"], "cat", ["./example_images/2007_000528.jpg", "./example_images/2007_000549.jpg"]]
132
+ ]
133
  ).launch(debug=True)
example_images/2007_000033.jpg ADDED
example_images/2007_000256.jpg ADDED
example_images/2007_000528.jpg ADDED
example_images/2007_000549.jpg ADDED
example_images/2007_000738.jpg ADDED
requirements.txt CHANGED
@@ -9,6 +9,5 @@ timm
9
  ml-collections
10
  ftfy
11
  tensorboard
12
- Google-Images-Search
13
  semantic-version
14
  pytz
 
9
  ml-collections
10
  ftfy
11
  tensorboard
 
12
  semantic-version
13
  pytz