Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ if not os.path.exists("/.dockerenv") and not os.path.exists("/kaggle"):
|
|
33 |
ensure_package("numpy", "1.23.5")
|
34 |
ensure_package("protobuf", "3.20.3")
|
35 |
ensure_package("tensorflow", "2.10.0")
|
36 |
-
ensure_package("opencv-python-headless", "4.7.0.72")
|
37 |
ensure_package("deepface", "0.0.79")
|
38 |
ensure_package("gradio", "3.50.2")
|
39 |
|
@@ -137,16 +137,13 @@ def find_faces(query_img, db_folder, threshold=0.70, model="VGG-Face"):
|
|
137 |
|
138 |
# Handle cloud storage paths and uploaded files
|
139 |
if isinstance(db_folder, str):
|
140 |
-
# Check if it's a Google Drive path
|
141 |
if db_folder.startswith("/content/drive"):
|
142 |
db_path = db_folder
|
143 |
else:
|
144 |
-
# Handle regular path
|
145 |
db_path = os.path.abspath(db_folder)
|
146 |
if not os.path.exists(db_path):
|
147 |
return None, "Invalid database path - directory does not exist"
|
148 |
else:
|
149 |
-
# Handle uploaded files
|
150 |
db_path = os.path.join(temp_dir, "db")
|
151 |
os.makedirs(db_path, exist_ok=True)
|
152 |
|
@@ -212,7 +209,6 @@ def find_faces(query_img, db_folder, threshold=0.70, model="VGG-Face"):
|
|
212 |
except:
|
213 |
continue
|
214 |
|
215 |
-
# Hide empty axes
|
216 |
for j in range(valid_matches+1, num_matches+1):
|
217 |
axes[j].axis("off")
|
218 |
|
@@ -305,6 +301,7 @@ def analyze_face(img, actions=['age', 'gender', 'race', 'emotion']):
|
|
305 |
emotion_conf = f"{conf:.1f}%"
|
306 |
break
|
307 |
|
|
|
308 |
ax = plt.subplot2grid((2, 4), (0 if i < 2 else 1, 2 + (i % 2)))
|
309 |
|
310 |
text = (
|
|
|
33 |
ensure_package("numpy", "1.23.5")
|
34 |
ensure_package("protobuf", "3.20.3")
|
35 |
ensure_package("tensorflow", "2.10.0")
|
36 |
+
ensure_package("opencv-python-headless", "4.7.0.72")
|
37 |
ensure_package("deepface", "0.0.79")
|
38 |
ensure_package("gradio", "3.50.2")
|
39 |
|
|
|
137 |
|
138 |
# Handle cloud storage paths and uploaded files
|
139 |
if isinstance(db_folder, str):
|
|
|
140 |
if db_folder.startswith("/content/drive"):
|
141 |
db_path = db_folder
|
142 |
else:
|
|
|
143 |
db_path = os.path.abspath(db_folder)
|
144 |
if not os.path.exists(db_path):
|
145 |
return None, "Invalid database path - directory does not exist"
|
146 |
else:
|
|
|
147 |
db_path = os.path.join(temp_dir, "db")
|
148 |
os.makedirs(db_path, exist_ok=True)
|
149 |
|
|
|
209 |
except:
|
210 |
continue
|
211 |
|
|
|
212 |
for j in range(valid_matches+1, num_matches+1):
|
213 |
axes[j].axis("off")
|
214 |
|
|
|
301 |
emotion_conf = f"{conf:.1f}%"
|
302 |
break
|
303 |
|
304 |
+
# Fixed line with proper parentheses
|
305 |
ax = plt.subplot2grid((2, 4), (0 if i < 2 else 1, 2 + (i % 2)))
|
306 |
|
307 |
text = (
|