Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,18 +44,21 @@ reversed_map = {
|
|
44 |
16: 'Will Smith'
|
45 |
}
|
46 |
def extract(zip_file, extract_path):
|
47 |
-
# Create a directory to store extracted images
|
48 |
os.makedirs(extract_path, exist_ok=True)
|
49 |
-
|
50 |
-
# Extract images from the ZIP file
|
51 |
with zipfile.ZipFile(zip_file, 'r') as zip_ref:
|
52 |
zip_ref.extractall(extract_path)
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
model = timm.create_model("rexnet_150", pretrained = True, num_classes = 17)
|
61 |
model.load_state_dict(torch.load('faces_best_model.pth', map_location=torch.device('cpu')))
|
|
|
44 |
16: 'Will Smith'
|
45 |
}
|
46 |
def extract(zip_file, extract_path):
|
|
|
47 |
os.makedirs(extract_path, exist_ok=True)
|
48 |
+
|
|
|
49 |
with zipfile.ZipFile(zip_file, 'r') as zip_ref:
|
50 |
zip_ref.extractall(extract_path)
|
51 |
+
|
52 |
+
for root, dirs, files in os.walk(extract_path):
|
53 |
+
for file in files:
|
54 |
+
if file.lower().endswith(('.png', '.jpg', '.jpeg', '.gif')): # Adjust file extensions as needed
|
55 |
+
image_path = os.path.join(root, file)
|
56 |
+
try:
|
57 |
+
image = Image.open(image_path)
|
58 |
+
# Process or display the image here
|
59 |
+
image.show()
|
60 |
+
except IOError as e:
|
61 |
+
print(f"Error opening image {image_path}: {e}")
|
62 |
|
63 |
model = timm.create_model("rexnet_150", pretrained = True, num_classes = 17)
|
64 |
model.load_state_dict(torch.load('faces_best_model.pth', map_location=torch.device('cpu')))
|