Files changed (1) hide show
  1. app.py +5 -26
app.py CHANGED
@@ -1,28 +1,7 @@
1
- from turtle import title
2
- import gradio as gr
3
- from transformers import pipeline
4
- import numpy as np
5
- from PIL import Image
6
 
 
7
 
8
- pipe = pipeline("zero-shot-image-classification", model="ashm/mini-test")
9
- images="dog.jpg"
10
-
11
- def shot(image, labels_text):
12
- PIL_image = Image.fromarray(np.uint8(image)).convert('RGB')
13
- labels = labels_text.split(",")
14
- res = pipe(images=PIL_image,
15
- candidate_labels=labels,
16
- hypothesis_template= "This is a photo of a {}")
17
- return {dic["label"]: dic["score"] for dic in res}
18
-
19
- iface = gr.Interface(shot,
20
- ["image", "text"],
21
- "label",
22
- examples=[["dog.jpg", "dog,cat,bird"],
23
- ["germany.jpg", "germany,belgium,colombia"],
24
- ["colombia.jpg", "germany,belgium,colombia"]],
25
- description="Add a picture and a list of labels separated by commas",
26
- title="Zero-shot Image Classification")
27
-
28
- iface.launch()
 
1
+ from fastapi import FastAPI
 
 
 
 
2
 
3
+ app = FastAPI()
4
 
5
+ @app.get("/")
6
+ def greet_json():
7
+ return {"Hello": "World!"}