Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,15 @@ from transformers import ViTImageProcessor,pipeline
|
|
6 |
model = ViTImageProcessor.from_pretrained('SeyedAli/Food-Image-Classification-VIT')
|
7 |
|
8 |
def FoodClassification(image):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
pipline = pipeline(task="image-classification", model=model)
|
10 |
-
output=pipline(model(Image.open(
|
11 |
return output
|
12 |
|
13 |
iface = gr.Interface(fn=FoodClassification, inputs="image", outputs="text")
|
|
|
6 |
model = ViTImageProcessor.from_pretrained('SeyedAli/Food-Image-Classification-VIT')
|
7 |
|
8 |
def FoodClassification(image):
|
9 |
+
# Encode your PIL Image as a JPEG without writing to disk
|
10 |
+
buffer = io.BytesIO(image)
|
11 |
+
YourImage.save(buffer, format='JPEG', quality=75)
|
12 |
+
|
13 |
+
# You probably want
|
14 |
+
desiredObject = buffer.getbuffer()
|
15 |
+
|
16 |
pipline = pipeline(task="image-classification", model=model)
|
17 |
+
output=pipline(model(Image.open(desiredObject), return_tensors='pt'))
|
18 |
return output
|
19 |
|
20 |
iface = gr.Interface(fn=FoodClassification, inputs="image", outputs="text")
|