Update app.py
Browse files
app.py
CHANGED
|
@@ -9,11 +9,7 @@ model = AutoModel.from_pretrained("ECOFRI/CXR-LLAVA-v2", trust_remote_code=True)
|
|
| 9 |
model = model.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 10 |
|
| 11 |
# Define the function to generate the report
|
| 12 |
-
def generate_report(image
|
| 13 |
-
# Check the API key
|
| 14 |
-
if api_key != os.getenv("API_KEY"):
|
| 15 |
-
return "Unauthorized access. Invalid API key."
|
| 16 |
-
|
| 17 |
image = Image.open(image).convert("RGB")
|
| 18 |
response = model.write_radiologic_report(image)
|
| 19 |
return response
|
|
@@ -21,10 +17,10 @@ def generate_report(image, api_key):
|
|
| 21 |
# Create the Gradio interface
|
| 22 |
interface = gr.Interface(
|
| 23 |
fn=generate_report,
|
| 24 |
-
inputs=[gr.Image(type="filepath", label="Upload
|
| 25 |
-
outputs=gr.Textbox(label="
|
| 26 |
-
title="
|
| 27 |
-
description="Upload
|
| 28 |
)
|
| 29 |
|
| 30 |
# Launch the interface with API enabled
|
|
|
|
| 9 |
model = model.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 10 |
|
| 11 |
# Define the function to generate the report
|
| 12 |
+
def generate_report(image):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
image = Image.open(image).convert("RGB")
|
| 14 |
response = model.write_radiologic_report(image)
|
| 15 |
return response
|
|
|
|
| 17 |
# Create the Gradio interface
|
| 18 |
interface = gr.Interface(
|
| 19 |
fn=generate_report,
|
| 20 |
+
inputs=[gr.Image(type="filepath", label="Upload Image"), gr.Textbox(label="API Key")],
|
| 21 |
+
outputs=gr.Textbox(label="Report"),
|
| 22 |
+
title="CXR Report Creator",
|
| 23 |
+
description="Upload an image to use with the CXR-LLAVA-v2 model."
|
| 24 |
)
|
| 25 |
|
| 26 |
# Launch the interface with API enabled
|