Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
# Load a medical AI model
|
5 |
+
MODEL_NAME = "TheBloke/medalpaca-7B-GGUF"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
|
8 |
+
|
9 |
+
def diagnose(symptoms):
|
10 |
+
prompt = f"I have the following symptoms: {symptoms}. What could it be?"
|
11 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
12 |
+
output = model.generate(**inputs, max_length=200)
|
13 |
+
return tokenizer.decode(output[0])
|
14 |
+
|
15 |
+
# Create a simple web app
|
16 |
+
interface = gr.Interface(
|
17 |
+
fn=diagnose,
|
18 |
+
inputs="text",
|
19 |
+
outputs="text",
|
20 |
+
title="AI Symptom Checker",
|
21 |
+
description="Enter your symptoms, and the AI will suggest possible conditions."
|
22 |
+
)
|
23 |
+
|
24 |
+
# Launch the app
|
25 |
+
interface.launch()
|