Spaces:
Runtime error
Runtime error
Commit
·
e3b5911
1
Parent(s):
798f51d
app update
Browse files- .gitignore +66 -0
- README.md +3 -3
- img_examples/known/ChengLong.jpg +0 -0
- img_examples/known/JasonStatham.jpg +0 -0
- img_examples/known/VinDiesel.jpg +0 -0
- img_examples/known/ZhenZidan.jpg +0 -0
- img_examples/unknown/test01.jpg +0 -0
- img_examples/unknown/test02.jpg +0 -0
- img_examples/unknown/test03.jpg +0 -0
- img_examples/unknown/test04.jpg +0 -0
- img_examples/unknown/test05.jpg +0 -0
- img_examples/unknown/test06.jpg +0 -0
- img_examples/unknown/test07.jpg +0 -0
- img_examples/unknown/test08.jpg +0 -0
- requirements.txt +3 -0
- style.css +7 -0
- util/fonts_opt.py +67 -0
.gitignore
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gradio YOLOv5 Det
|
| 2 |
+
# 创建人:曾逸夫
|
| 3 |
+
# 项目地址:https://gitee.com/CV_Lab/gradio_yolov5_det
|
| 4 |
+
|
| 5 |
+
# 图片格式
|
| 6 |
+
*.jpg
|
| 7 |
+
*.jpeg
|
| 8 |
+
*.png
|
| 9 |
+
*.svg
|
| 10 |
+
*.gif
|
| 11 |
+
|
| 12 |
+
# 视频格式
|
| 13 |
+
*.mp4
|
| 14 |
+
*.avi
|
| 15 |
+
.ipynb_checkpoints
|
| 16 |
+
/__pycache__
|
| 17 |
+
*/__pycache__
|
| 18 |
+
|
| 19 |
+
# 日志格式
|
| 20 |
+
*.log
|
| 21 |
+
*.data
|
| 22 |
+
*.txt
|
| 23 |
+
|
| 24 |
+
# 生成文件
|
| 25 |
+
*.pdf
|
| 26 |
+
*.xlsx
|
| 27 |
+
*.csv
|
| 28 |
+
|
| 29 |
+
# 参数文件
|
| 30 |
+
*.yaml
|
| 31 |
+
*.json
|
| 32 |
+
|
| 33 |
+
# 压缩文件格式
|
| 34 |
+
*.zip
|
| 35 |
+
*.tar
|
| 36 |
+
*.tar.gz
|
| 37 |
+
*.rar
|
| 38 |
+
|
| 39 |
+
# 字体格式
|
| 40 |
+
*.ttc
|
| 41 |
+
*.ttf
|
| 42 |
+
*.otf
|
| 43 |
+
*.pkl
|
| 44 |
+
|
| 45 |
+
# 模型文件
|
| 46 |
+
*.pt
|
| 47 |
+
*.db
|
| 48 |
+
|
| 49 |
+
/flagged
|
| 50 |
+
/run
|
| 51 |
+
!requirements.txt
|
| 52 |
+
!cls_name/*
|
| 53 |
+
!model_config/*
|
| 54 |
+
!img_examples/*
|
| 55 |
+
!img_examples/known/*
|
| 56 |
+
!img_examples/unknown/*
|
| 57 |
+
|
| 58 |
+
!requirements.txt
|
| 59 |
+
!.pre-commit-config.yaml
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
app.py
|
| 63 |
+
test.py
|
| 64 |
+
test*.py
|
| 65 |
+
|
| 66 |
+
model_download.py
|
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
title: FaceRecognition
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.1.1
|
| 8 |
app_file: app.py
|
|
|
|
| 1 |
---
|
| 2 |
title: FaceRecognition
|
| 3 |
+
emoji: 🚀
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.1.1
|
| 8 |
app_file: app.py
|
img_examples/known/ChengLong.jpg
ADDED
|
img_examples/known/JasonStatham.jpg
ADDED
|
img_examples/known/VinDiesel.jpg
ADDED
|
img_examples/known/ZhenZidan.jpg
ADDED
|
img_examples/unknown/test01.jpg
ADDED
|
img_examples/unknown/test02.jpg
ADDED
|
img_examples/unknown/test03.jpg
ADDED
|
img_examples/unknown/test04.jpg
ADDED
|
img_examples/unknown/test05.jpg
ADDED
|
img_examples/unknown/test06.jpg
ADDED
|
img_examples/unknown/test07.jpg
ADDED
|
img_examples/unknown/test08.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
face_recognition
|
| 2 |
+
gradio
|
| 3 |
+
streamlit
|
style.css
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
h1 {
|
| 2 |
+
text-align: center;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
#content_align {
|
| 6 |
+
text-align: center;
|
| 7 |
+
}
|
util/fonts_opt.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 字体管理
|
| 2 |
+
# 创建人:曾逸夫
|
| 3 |
+
# 创建时间:2022-05-01
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
import wget
|
| 10 |
+
from rich.console import Console
|
| 11 |
+
|
| 12 |
+
ROOT_PATH = sys.path[0] # 项目根目录
|
| 13 |
+
|
| 14 |
+
# 中文、英文、俄语、西班牙语、阿拉伯语、韩语
|
| 15 |
+
fonts_list = ["SimSun.ttf", "TimesNewRoman.ttf", "malgun.ttf"] # 字体列表
|
| 16 |
+
fonts_suffix = ["ttc", "ttf", "otf"] # 字体后缀
|
| 17 |
+
|
| 18 |
+
data_url_dict = {
|
| 19 |
+
"SimSun.ttf": "https://gitee.com/CV_Lab/gradio_yolov5_det/attach_files/1053539/download/SimSun.ttf",
|
| 20 |
+
"TimesNewRoman.ttf": "https://gitee.com/CV_Lab/gradio_yolov5_det/attach_files/1053537/download/TimesNewRoman.ttf",
|
| 21 |
+
"malgun.ttf": "https://gitee.com/CV_Lab/gradio_yolov5_det/attach_files/1053538/download/malgun.ttf",}
|
| 22 |
+
|
| 23 |
+
console = Console()
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# 创建字体库
|
| 27 |
+
def add_fronts(font_diff):
|
| 28 |
+
|
| 29 |
+
global font_name
|
| 30 |
+
|
| 31 |
+
for k, v in data_url_dict.items():
|
| 32 |
+
if k in font_diff:
|
| 33 |
+
font_name = v.split("/")[-1] # 字体名称
|
| 34 |
+
Path(f"{ROOT_PATH}/fonts").mkdir(parents=True, exist_ok=True) # 创建目录
|
| 35 |
+
|
| 36 |
+
file_path = f"{ROOT_PATH}/fonts/{font_name}" # 字体路径
|
| 37 |
+
|
| 38 |
+
try:
|
| 39 |
+
# 下载字体文件
|
| 40 |
+
wget.download(v, file_path)
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print("路径错误!程序结束!")
|
| 43 |
+
print(e)
|
| 44 |
+
sys.exit()
|
| 45 |
+
else:
|
| 46 |
+
print()
|
| 47 |
+
console.print(f"{font_name} [bold green]字体文件下载完成![/bold green] 已保存至:{file_path}")
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# 判断字体文件
|
| 51 |
+
def is_fonts(fonts_dir):
|
| 52 |
+
if os.path.isdir(fonts_dir):
|
| 53 |
+
# 如果字体库存在
|
| 54 |
+
f_list = os.listdir(fonts_dir) # 本地字体库
|
| 55 |
+
|
| 56 |
+
font_diff = list(set(fonts_list).difference(set(f_list)))
|
| 57 |
+
|
| 58 |
+
if font_diff != []:
|
| 59 |
+
# 字体不存在
|
| 60 |
+
console.print("[bold red]字体不存在,正在加载。。。[/bold red]")
|
| 61 |
+
add_fronts(font_diff) # 创建字体库
|
| 62 |
+
else:
|
| 63 |
+
console.print(f"{fonts_list}[bold green]字体已存在![/bold green]")
|
| 64 |
+
else:
|
| 65 |
+
# 字体库不存在,创建字体库
|
| 66 |
+
console.print("[bold red]字体库不存在,正在创建。。。[/bold red]")
|
| 67 |
+
add_fronts(fonts_list) # 创建字体库
|