Spaces:
Running
Running
Update apps/gradio_app/components.py
Browse files- apps/gradio_app/components.py +95 -95
apps/gradio_app/components.py
CHANGED
@@ -1,96 +1,96 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
# File listing functions
|
4 |
-
def list_reference_files():
|
5 |
-
ref_dir = "data/reference_data/"
|
6 |
-
try:
|
7 |
-
files = [os.path.join(ref_dir, f) for f in os.listdir(ref_dir) if f.endswith(".json")]
|
8 |
-
return files if files else ["No .json files found in data/reference_data/"]
|
9 |
-
except FileNotFoundError:
|
10 |
-
return ["Directory data/reference_data/ not found"]
|
11 |
-
except Exception as e:
|
12 |
-
return [f"Error listing files: {str(e)}"]
|
13 |
-
|
14 |
-
def list_mapping_files():
|
15 |
-
map_dir = "ckpts/"
|
16 |
-
try:
|
17 |
-
files = [os.path.join(map_dir, f) for f in os.listdir(map_dir) if f.endswith(".json")]
|
18 |
-
return files if files else ["No .json files found in ckpts/"]
|
19 |
-
except FileNotFoundError:
|
20 |
-
return ["Directory ckpts/ not found"]
|
21 |
-
except Exception as e:
|
22 |
-
return [f"Error listing files: {str(e)}"]
|
23 |
-
|
24 |
-
def list_classifier_files():
|
25 |
-
clf_dir = "ckpts/"
|
26 |
-
try:
|
27 |
-
files = [os.path.join(clf_dir, f) for f in os.listdir(clf_dir) if f.endswith(".pth")]
|
28 |
-
return files if files else ["No .pth files found in ckpts/"]
|
29 |
-
except FileNotFoundError:
|
30 |
-
return ["Directory ckpts/ not found"]
|
31 |
-
except Exception as e:
|
32 |
-
return [f"Error listing files: {str(e)}"]
|
33 |
-
|
34 |
-
def list_edgeface_files():
|
35 |
-
ef_dir = "ckpts/idiap/"
|
36 |
-
try:
|
37 |
-
files = [os.path.join(ef_dir, f) for f in os.listdir(ef_dir) if f.endswith(".pt")]
|
38 |
-
return files if files else ["No .pt files found in ckpts/idiap/"]
|
39 |
-
except FileNotFoundError:
|
40 |
-
return ["Directory ckpts/idiap/ not found"]
|
41 |
-
except Exception as e:
|
42 |
-
return [f"Error listing files: {str(e)}"]
|
43 |
-
|
44 |
-
CONTENT_DESCRIPTION = """
|
45 |
-
**SlimFace: Advanced Face Classification with TorchVision Backbones**
|
46 |
-
"""
|
47 |
-
|
48 |
-
CONTENT_IN_1 = """
|
49 |
-
SlimFace empowers developers to build high-accuracy face classification models
|
50 |
-
"""
|
51 |
-
CONTENT_IN_2 = """
|
52 |
-
<p class="source">
|
53 |
-
For more information, you can follow below:<br>
|
54 |
-
Source code:
|
55 |
-
<a class="badge" href="https://github.com/danhtran2mind/SlimFace">
|
56 |
-
<img src="https://img.shields.io/badge/GitHub-danhtran2mind%2FSlimFace-blue?style=flat" alt="GitHub Repo">
|
57 |
-
</a>,
|
58 |
-
Author:
|
59 |
-
<a class="badge" href="https://github.com/danhtran2mind">
|
60 |
-
<img src="https://img.shields.io/badge/GitHub-danhtran2mind-blue?style=flat" alt="GitHub Profile">
|
61 |
-
</a>,
|
62 |
-
PyTorch Docs:
|
63 |
-
<a class="badge" href="https://docs.pytorch.org/vision/main/models.html">
|
64 |
-
<img src="https://img.shields.io/badge/PyTorch-Pretrain%20Model%20Docs-blue?style=flat" alt="PyTorch Docs">
|
65 |
-
</a>
|
66 |
-
</p>
|
67 |
-
"""
|
68 |
-
|
69 |
-
|
70 |
-
CONTENT_OUTTRO = """
|
71 |
-
## More Information about SlimFace
|
72 |
-
"""
|
73 |
-
CONTENT_OUT_1 = """
|
74 |
-
<div class="quote-container">
|
75 |
-
<p>
|
76 |
-
This project leverages code from
|
77 |
-
<a class="badge" href="https://github.com/otroshi/edgeface">
|
78 |
-
<img src="https://img.shields.io/badge/Built%20on-otroshi%2Fedgeface-blue?style=flat&logo=github" alt="Built on edgeface">
|
79 |
-
</a>
|
80 |
-
by
|
81 |
-
<a class="badge" href="https://github.com/otroshi">
|
82 |
-
<img src="https://img.shields.io/badge/GitHub-Hatef_Otroshi-blue?style=flat&logo=github" alt="Hatef Otroshi">
|
83 |
-
</a>,
|
84 |
-
with our own bug fixes and enhancements available at
|
85 |
-
<a class="badge" href="https://github.com/danhtran2mind/edgeface/tree/main/face_alignment">
|
86 |
-
<img src="https://img.shields.io/badge/GitHub-danhtran2mind%2Fedgeface-blue?style=flat&logo=github" alt="Edgeface Enhancements">
|
87 |
-
</a>.
|
88 |
-
</p>
|
89 |
-
</div>
|
90 |
-
"""
|
91 |
-
CONTENT_OUT_2 = """
|
92 |
-
**Supported Architectures:**
|
93 |
-
- **EfficientNet**: B0-B7 and V2 (Small, Medium, Large) for balanced performance and efficiency. πΈ
|
94 |
-
- **RegNet**: X/Y series (400MF to 128GF) for optimized computation across diverse hardware. π»
|
95 |
-
- **Vision Transformers (ViT)**: B_16, B_32, H_14, L_16, L_32 for cutting-edge feature extraction. π
|
96 |
"""
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
# File listing functions
|
4 |
+
def list_reference_files():
|
5 |
+
ref_dir = "data/reference_data/"
|
6 |
+
try:
|
7 |
+
files = [os.path.join(ref_dir, f) for f in os.listdir(ref_dir) if f.endswith(".json")]
|
8 |
+
return files if files else ["No .json files found in data/reference_data/"]
|
9 |
+
except FileNotFoundError:
|
10 |
+
return ["Directory data/reference_data/ not found"]
|
11 |
+
except Exception as e:
|
12 |
+
return [f"Error listing files: {str(e)}"]
|
13 |
+
|
14 |
+
def list_mapping_files():
|
15 |
+
map_dir = "ckpts/"
|
16 |
+
try:
|
17 |
+
files = [os.path.join(map_dir, f) for f in os.listdir(map_dir) if f.endswith(".json")]
|
18 |
+
return files if files else ["No .json files found in ckpts/"]
|
19 |
+
except FileNotFoundError:
|
20 |
+
return ["Directory ckpts/ not found"]
|
21 |
+
except Exception as e:
|
22 |
+
return [f"Error listing files: {str(e)}"]
|
23 |
+
|
24 |
+
def list_classifier_files():
|
25 |
+
clf_dir = "ckpts/"
|
26 |
+
try:
|
27 |
+
files = [os.path.join(clf_dir, f) for f in os.listdir(clf_dir) if f.endswith(".pth")]
|
28 |
+
return files if files else ["No .pth files found in ckpts/"]
|
29 |
+
except FileNotFoundError:
|
30 |
+
return ["Directory ckpts/ not found"]
|
31 |
+
except Exception as e:
|
32 |
+
return [f"Error listing files: {str(e)}"]
|
33 |
+
|
34 |
+
def list_edgeface_files():
|
35 |
+
ef_dir = "ckpts/idiap/"
|
36 |
+
try:
|
37 |
+
files = [os.path.join(ef_dir, f) for f in os.listdir(ef_dir) if f.endswith(".pt")]
|
38 |
+
return files if files else ["No .pt files found in ckpts/idiap/"]
|
39 |
+
except FileNotFoundError:
|
40 |
+
return ["Directory ckpts/idiap/ not found"]
|
41 |
+
except Exception as e:
|
42 |
+
return [f"Error listing files: {str(e)}"]
|
43 |
+
|
44 |
+
CONTENT_DESCRIPTION = """
|
45 |
+
**SlimFace: Advanced Face Classification with TorchVision Backbones**
|
46 |
+
"""
|
47 |
+
|
48 |
+
CONTENT_IN_1 = """
|
49 |
+
SlimFace empowers developers to build high-accuracy face classification models by leveraging TorchVision's powerful pre-trained architectures through a transfer learning approach. π It provides a flexible, efficient, and scalable solution for facial recognition, supporting training on custom datasets and inference to deliver top-tier performance for custom applications.
|
50 |
+
"""
|
51 |
+
CONTENT_IN_2 = """
|
52 |
+
<p class="source">
|
53 |
+
For more information, you can follow below:<br>
|
54 |
+
Source code:
|
55 |
+
<a class="badge" href="https://github.com/danhtran2mind/SlimFace">
|
56 |
+
<img src="https://img.shields.io/badge/GitHub-danhtran2mind%2FSlimFace-blue?style=flat" alt="GitHub Repo">
|
57 |
+
</a>,
|
58 |
+
Author:
|
59 |
+
<a class="badge" href="https://github.com/danhtran2mind">
|
60 |
+
<img src="https://img.shields.io/badge/GitHub-danhtran2mind-blue?style=flat" alt="GitHub Profile">
|
61 |
+
</a>,
|
62 |
+
PyTorch Docs:
|
63 |
+
<a class="badge" href="https://docs.pytorch.org/vision/main/models.html">
|
64 |
+
<img src="https://img.shields.io/badge/PyTorch-Pretrain%20Model%20Docs-blue?style=flat" alt="PyTorch Docs">
|
65 |
+
</a>
|
66 |
+
</p>
|
67 |
+
"""
|
68 |
+
|
69 |
+
|
70 |
+
CONTENT_OUTTRO = """
|
71 |
+
## More Information about SlimFace
|
72 |
+
"""
|
73 |
+
CONTENT_OUT_1 = """
|
74 |
+
<div class="quote-container">
|
75 |
+
<p>
|
76 |
+
This project leverages code from
|
77 |
+
<a class="badge" href="https://github.com/otroshi/edgeface">
|
78 |
+
<img src="https://img.shields.io/badge/Built%20on-otroshi%2Fedgeface-blue?style=flat&logo=github" alt="Built on edgeface">
|
79 |
+
</a>
|
80 |
+
by
|
81 |
+
<a class="badge" href="https://github.com/otroshi">
|
82 |
+
<img src="https://img.shields.io/badge/GitHub-Hatef_Otroshi-blue?style=flat&logo=github" alt="Hatef Otroshi">
|
83 |
+
</a>,
|
84 |
+
with our own bug fixes and enhancements available at
|
85 |
+
<a class="badge" href="https://github.com/danhtran2mind/edgeface/tree/main/face_alignment">
|
86 |
+
<img src="https://img.shields.io/badge/GitHub-danhtran2mind%2Fedgeface-blue?style=flat&logo=github" alt="Edgeface Enhancements">
|
87 |
+
</a>.
|
88 |
+
</p>
|
89 |
+
</div>
|
90 |
+
"""
|
91 |
+
CONTENT_OUT_2 = """
|
92 |
+
**Supported Architectures:**
|
93 |
+
- **EfficientNet**: B0-B7 and V2 (Small, Medium, Large) for balanced performance and efficiency. πΈ
|
94 |
+
- **RegNet**: X/Y series (400MF to 128GF) for optimized computation across diverse hardware. π»
|
95 |
+
- **Vision Transformers (ViT)**: B_16, B_32, H_14, L_16, L_32 for cutting-edge feature extraction. π
|
96 |
"""
|