egmaminta commited on
Commit
0613c3d
·
1 Parent(s): ce51d24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -1,3 +1,16 @@
1
- import gradio as gr
 
2
 
3
- gr.Interface.load('huggingface/vincentclaes/mit-indoor-scenes').launch(inbrowser=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoFeatureExtractor, AutoModelForImageClassification
2
+ import gradio
3
 
4
+ extractor = AutoFeatureExtractor.from_pretrained("vincentclaes/mit-indoor-scenes")
5
+ model = AutoModelForImageClassification.from_pretrained("vincentclaes/mit-indoor-scenes")
6
+
7
+ def classify(image):
8
+ inputs = extractor(images=image, return_tensors='pt')
9
+ outputs = model(**inputs)
10
+ last_hidden_states = outputs.last_hidden_state
11
+ return last_hidden_states
12
+
13
+ gradio.Interface(fn=classify,
14
+ inputs=gradio.inputs.Image(self, shape=(224,224), image_mode='RGB', source='upload', tool='editor', type='PIL.image', label=None, optional=False),
15
+ outputs=gradio.outputs.Label(self, num_top_classes=5),
16
+ allow_flagging='never').launch(inbrowser=True)