MnM369's picture
A new gradio app
ec5fdf4 verified
import gradio as gr
# def image_to_base64_str(pil_image):
# byte_arr = io.BytesIO()
# pil_image.save(byte_arr, format='PNG')
# byte_arr = byte_arr.getvalue()
# return str(base64.b64encode(byte_arr).decode('utf-8'))
# def captioner(image):
# base64_image = image_to_base64_str(image)
# result = get_completion(base64_image)
# return result[0]['generated_text']
from transformers import pipeline
import gradio as gr
pipeline = pipeline("image-classification", model="google/vit-base-patch16-224")
gr.Interface.from_pipeline(pipeline).launch()
gr.close_all()
# demo = gr.Interface(fn=captioner,
# inputs=[gr.Image(label="Upload image", type="pil")],
# outputs=[gr.Textbox(label="Caption")],
# title="Image Captioning with BLIP",
# description="Caption any image using the BLIP model",
# allow_flagging="never",
# examples=["christmas_dog.jpeg", "bird_flight.jpeg", "cow.jpeg"])
# demo.launch(share=True, server_port=int(os.environ['PORT1']))