Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,16 @@
|
|
1 |
-
import
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|