Spaces:
Runtime error
Runtime error
| from transformers import pipeline | |
| import gradio as gr | |
| import base64 | |
| import io | |
| # calling pipeline to get_completion | |
| get_completion = pipeline("image-classification",model="naycrispim/modelo-exercicio-sirius") | |
| def summarize(input): | |
| output = get_completion(input) | |
| return output[0]['generated_text'] | |
| 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(image) | |
| return result[0]['generated_text'] | |
| gr.close_all() | |
| demo = gr.Interface(fn=captioner, | |
| inputs=[gr.Image(label="Upload image", type="pil")], | |
| outputs=[gr.Textbox(label="Caption")], | |
| title="Image Captioning Application", | |
| description="Caption the image you'd like to upload", | |
| allow_flagging="never") | |
| demo.launch() |