Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,72 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
pipe = pipeline(
|
| 5 |
"text-generation",
|
| 6 |
model="Qwen/Qwen2.5-1.5B-Instruct"
|
| 7 |
)
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
result = pipe(
|
| 11 |
-
|
| 12 |
-
max_new_tokens=
|
| 13 |
do_sample=True,
|
| 14 |
temperature=0.7
|
| 15 |
)
|
| 16 |
|
| 17 |
return result[0]["generated_text"]
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
|
|
|
| 30 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
+
# -----------------------------
|
| 7 |
+
# AI MODEL
|
| 8 |
+
# -----------------------------
|
| 9 |
pipe = pipeline(
|
| 10 |
"text-generation",
|
| 11 |
model="Qwen/Qwen2.5-1.5B-Instruct"
|
| 12 |
)
|
| 13 |
|
| 14 |
+
# -----------------------------
|
| 15 |
+
# ANALYSIS FUNCTION
|
| 16 |
+
# -----------------------------
|
| 17 |
+
def analyze(image, question):
|
| 18 |
+
if image is None:
|
| 19 |
+
return "Please upload a DNA/RNA or medical image for analysis."
|
| 20 |
+
|
| 21 |
+
prompt = f"""
|
| 22 |
+
You are VISION-LINK AI, an advanced biotech and healthcare assistant.
|
| 23 |
+
|
| 24 |
+
User Question:
|
| 25 |
+
{question}
|
| 26 |
+
|
| 27 |
+
Provide a professional biomedical analysis response.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
result = pipe(
|
| 31 |
+
prompt,
|
| 32 |
+
max_new_tokens=180,
|
| 33 |
do_sample=True,
|
| 34 |
temperature=0.7
|
| 35 |
)
|
| 36 |
|
| 37 |
return result[0]["generated_text"]
|
| 38 |
|
| 39 |
+
# -----------------------------
|
| 40 |
+
# CUSTOM CSS
|
| 41 |
+
# -----------------------------
|
| 42 |
+
custom_css = """
|
| 43 |
+
body {
|
| 44 |
+
background: linear-gradient(135deg, #0f172a, #1e293b);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.gradio-container {
|
| 48 |
+
font-family: 'Segoe UI', sans-serif;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
#title {
|
| 52 |
+
text-align: center;
|
| 53 |
+
font-size: 42px;
|
| 54 |
+
font-weight: bold;
|
| 55 |
+
color: white;
|
| 56 |
+
margin-bottom: 10px;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
#subtitle {
|
| 60 |
+
text-align: center;
|
| 61 |
+
color: #cbd5e1;
|
| 62 |
+
margin-bottom: 30px;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
footer {
|
| 66 |
+
visibility: hidden;
|
| 67 |
+
}
|
| 68 |
+
"""
|
| 69 |
|
| 70 |
+
# -----------------------------
|
| 71 |
+
# UI
|
| 72 |
demo.launch()
|