MnM369 commited on
Commit
ec5fdf4
·
verified ·
1 Parent(s): b0a0e43

A new gradio app

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # def image_to_base64_str(pil_image):
4
+ # byte_arr = io.BytesIO()
5
+ # pil_image.save(byte_arr, format='PNG')
6
+ # byte_arr = byte_arr.getvalue()
7
+ # return str(base64.b64encode(byte_arr).decode('utf-8'))
8
+
9
+ # def captioner(image):
10
+ # base64_image = image_to_base64_str(image)
11
+ # result = get_completion(base64_image)
12
+ # return result[0]['generated_text']
13
+
14
+ from transformers import pipeline
15
+ import gradio as gr
16
+
17
+ pipeline = pipeline("image-classification", model="google/vit-base-patch16-224")
18
+ gr.Interface.from_pipeline(pipeline).launch()
19
+
20
+ gr.close_all()
21
+ # demo = gr.Interface(fn=captioner,
22
+ # inputs=[gr.Image(label="Upload image", type="pil")],
23
+ # outputs=[gr.Textbox(label="Caption")],
24
+ # title="Image Captioning with BLIP",
25
+ # description="Caption any image using the BLIP model",
26
+ # allow_flagging="never",
27
+ # examples=["christmas_dog.jpeg", "bird_flight.jpeg", "cow.jpeg"])
28
+
29
+ # demo.launch(share=True, server_port=int(os.environ['PORT1']))