Spaces:
Runtime error
Runtime error
| import torch | |
| import re | |
| import gradio as gr | |
| from transformers import pipeline | |
| device='cpu' | |
| image_captioner = pipeline("image-to-text", | |
| model="eduardofarina/MultimodalXray", | |
| device = device) | |
| generate_kwargs = { | |
| "max_length":160 | |
| } | |
| def predict(image): | |
| image = image.convert('RGB') | |
| with torch.no_grad(): | |
| caption = image_captioner(image, generate_kwargs=generate_kwargs) | |
| return caption[0]['generated_text'] | |
| input = gr.inputs.Image(label="Upload any Chest Xray", type = 'pil', optional=True) | |
| output = gr.outputs.Textbox(type="text",label="Preliminary Radiology Report") | |
| title = "X-Ray Report Generation " | |
| description = "Not for clinical use. The examples are cases from Radiopaedia" | |
| examples = ["example_1.jpeg", "example_2.jpeg"] | |
| interface = gr.Interface( | |
| fn=predict, | |
| description=description, | |
| inputs = input, | |
| examples = examples, | |
| theme="grass", | |
| outputs=output, | |
| title=title, | |
| ) | |
| interface.launch(debug=True) |