mennasaleh commited on
Commit
9280452
1 Parent(s): 5bf0399

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -0
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as a
2
+ import cv2 as b
3
+ import numpy as c
4
+ import pandas as d
5
+ from yolov8 import e
6
+
7
+ f = d.read_csv("skin_recommendations.csv")
8
+
9
+ html_style = """
10
+ <style>
11
+ .container { padding: 20px; background-color: #f9f9f9; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);}
12
+ .title { color: #ff69b4; font-size: 36px; text-align: center; margin-bottom: 30px;}
13
+ .subheader { color: #ff69b4; font-size: 24px; margin-top: 20px;}
14
+ .image-container { margin-top: 20px; text-align: center;}
15
+ </style>
16
+ """
17
+ a.markdown(html_style, unsafe_allow_html=True)
18
+
19
+ a.markdown("<h1 class='title'>AI Skin Analyzer</h1>", unsafe_allow_html=True)
20
+
21
+ # Skin Analysis Question
22
+ g = a.text_input("Describe your skin concern:",
23
+ value="Is there anything unusual I should be aware of?")
24
+
25
+ # Additional questions
26
+ h = a.text_input("Have you experienced any skin irritation recently?",
27
+ value="Yes/No")
28
+
29
+ i = a.text_input("Are you currently using any skincare products?",
30
+ value="Yes/No")
31
+
32
+ j = a.text_input("Do you have any known allergies?",
33
+ value="Yes/No")
34
+
35
+ k = a.text_input("Do you smoke or consume alcohol regularly?",
36
+ value="Yes/No")
37
+
38
+ l = a.text_input("How many hours of sleep do you get per night?",
39
+ value="7")
40
+
41
+ m = a.text_input("How many glasses of water do you drink per day?",
42
+ value="8")
43
+
44
+ # Image Upload
45
+ n = a.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
46
+
47
+ if n is not None:
48
+ o = b.imdecode(c.fromstring(n.read(), c.uint8), 1)
49
+ a.image(o, caption="Uploaded Image", use_column_width=True)
50
+
51
+ a.markdown("<h2 class='subheader'>Model Predictions:</h2>", unsafe_allow_html=True)
52
+
53
+ # Load YOLOv8 models
54
+ p = []
55
+ p.append(e('yolov8n.pt'))
56
+ p.append(e('yolov8s.pt'))
57
+ p.append(e('yolov8m.pt'))
58
+ p.append(e('yolov8l.pt'))
59
+
60
+ # Perform object detection with each model
61
+ for q, r in enumerate(p):
62
+ a.markdown(f"<h3 class='subheader'>Model {q+1}</h3>", unsafe_allow_html=True)
63
+ s = r(o)
64
+ s.render()
65
+ a.image(s.imgs[0], use_column_width=True)
66
+
67
+ # Recommendations Based on Question
68
+ t = u(g)
69
+
70
+ a.markdown("<h2 class='subheader'>Recommendations:</h2>", unsafe_allow_html=True)
71
+ for v in t:
72
+ w = f[f['Condition'] == v]
73
+ if not w.empty:
74
+ a.image(w['Image'].values[0], caption=v, use_column_width=True)
75
+ a.write(w['Advice'].values[0])
76
+
77
+ # Helper function (needs improvement for accurate matching)
78
+ def u(x):
79
+ y = ["acne", "spots", "dry"] # Example keywords
80
+ z = []
81
+ for aa in y:
82
+ if aa in x.lower():
83
+ z.append(aa.capitalize())
84
+ return z