Spaces:
Runtime error
Runtime error
KupynOrest
commited on
Commit
·
6dc8b4e
1
Parent(s):
2f2f500
app fixed
Browse files- .idea/inspectionProfiles/Project_Default.xml +83 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- .idea/vgg_heads.iml +8 -0
- app.py +19 -135
- requirements.txt +2 -6
.idea/inspectionProfiles/Project_Default.xml
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<component name="InspectionProjectProfileManager">
|
| 2 |
+
<profile version="1.0">
|
| 3 |
+
<option name="myName" value="Project Default" />
|
| 4 |
+
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
| 5 |
+
<Languages>
|
| 6 |
+
<language minSize="109" name="Python" />
|
| 7 |
+
</Languages>
|
| 8 |
+
</inspection_tool>
|
| 9 |
+
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
| 10 |
+
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
| 11 |
+
<option name="ignoredPackages">
|
| 12 |
+
<value>
|
| 13 |
+
<list size="55">
|
| 14 |
+
<item index="0" class="java.lang.String" itemvalue="torchmetrics" />
|
| 15 |
+
<item index="1" class="java.lang.String" itemvalue="albumentations_experimental" />
|
| 16 |
+
<item index="2" class="java.lang.String" itemvalue="OCHumanApi" />
|
| 17 |
+
<item index="3" class="java.lang.String" itemvalue="pytorchcv" />
|
| 18 |
+
<item index="4" class="java.lang.String" itemvalue="fire" />
|
| 19 |
+
<item index="5" class="java.lang.String" itemvalue="xmltodict" />
|
| 20 |
+
<item index="6" class="java.lang.String" itemvalue="Cython" />
|
| 21 |
+
<item index="7" class="java.lang.String" itemvalue="torch_optimizer" />
|
| 22 |
+
<item index="8" class="java.lang.String" itemvalue="gorilla" />
|
| 23 |
+
<item index="9" class="java.lang.String" itemvalue="timm" />
|
| 24 |
+
<item index="10" class="java.lang.String" itemvalue="smplx" />
|
| 25 |
+
<item index="11" class="java.lang.String" itemvalue="h5py" />
|
| 26 |
+
<item index="12" class="java.lang.String" itemvalue="torch" />
|
| 27 |
+
<item index="13" class="java.lang.String" itemvalue="imagesize" />
|
| 28 |
+
<item index="14" class="java.lang.String" itemvalue="mlflow" />
|
| 29 |
+
<item index="15" class="java.lang.String" itemvalue="pandas" />
|
| 30 |
+
<item index="16" class="java.lang.String" itemvalue="pytorch-lightning" />
|
| 31 |
+
<item index="17" class="java.lang.String" itemvalue="face_recognition" />
|
| 32 |
+
<item index="18" class="java.lang.String" itemvalue="hydra-core" />
|
| 33 |
+
<item index="19" class="java.lang.String" itemvalue="toolkit" />
|
| 34 |
+
<item index="20" class="java.lang.String" itemvalue="pytorch-toolbelt" />
|
| 35 |
+
<item index="21" class="java.lang.String" itemvalue="test_tube" />
|
| 36 |
+
<item index="22" class="java.lang.String" itemvalue="deepdish" />
|
| 37 |
+
<item index="23" class="java.lang.String" itemvalue="pycocotools" />
|
| 38 |
+
<item index="24" class="java.lang.String" itemvalue="albumentations" />
|
| 39 |
+
<item index="25" class="java.lang.String" itemvalue="scikit-learn" />
|
| 40 |
+
<item index="26" class="java.lang.String" itemvalue="cupy" />
|
| 41 |
+
<item index="27" class="java.lang.String" itemvalue="wheel" />
|
| 42 |
+
<item index="28" class="java.lang.String" itemvalue="chumpy" />
|
| 43 |
+
<item index="29" class="java.lang.String" itemvalue="numpy" />
|
| 44 |
+
<item index="30" class="java.lang.String" itemvalue="torchvision" />
|
| 45 |
+
<item index="31" class="java.lang.String" itemvalue="coloredlogs" />
|
| 46 |
+
<item index="32" class="java.lang.String" itemvalue="fastapi" />
|
| 47 |
+
<item index="33" class="java.lang.String" itemvalue="pydantic" />
|
| 48 |
+
<item index="34" class="java.lang.String" itemvalue="diffusers" />
|
| 49 |
+
<item index="35" class="java.lang.String" itemvalue="uvicorn" />
|
| 50 |
+
<item index="36" class="java.lang.String" itemvalue="Pillow" />
|
| 51 |
+
<item index="37" class="java.lang.String" itemvalue="transformers" />
|
| 52 |
+
<item index="38" class="java.lang.String" itemvalue="opencv-python" />
|
| 53 |
+
<item index="39" class="java.lang.String" itemvalue="rembg" />
|
| 54 |
+
<item index="40" class="java.lang.String" itemvalue="pyopengl" />
|
| 55 |
+
<item index="41" class="java.lang.String" itemvalue="safetensors" />
|
| 56 |
+
<item index="42" class="java.lang.String" itemvalue="mesh" />
|
| 57 |
+
<item index="43" class="java.lang.String" itemvalue="controlnet_aux" />
|
| 58 |
+
<item index="44" class="java.lang.String" itemvalue="xformers" />
|
| 59 |
+
<item index="45" class="java.lang.String" itemvalue="nltk" />
|
| 60 |
+
<item index="46" class="java.lang.String" itemvalue="matplotlib" />
|
| 61 |
+
<item index="47" class="java.lang.String" itemvalue="ultralytics" />
|
| 62 |
+
<item index="48" class="java.lang.String" itemvalue="accelerate" />
|
| 63 |
+
<item index="49" class="java.lang.String" itemvalue="compel" />
|
| 64 |
+
<item index="50" class="java.lang.String" itemvalue="tinydb" />
|
| 65 |
+
<item index="51" class="java.lang.String" itemvalue="gliner" />
|
| 66 |
+
<item index="52" class="java.lang.String" itemvalue="tensorflow" />
|
| 67 |
+
<item index="53" class="java.lang.String" itemvalue="kornia" />
|
| 68 |
+
<item index="54" class="java.lang.String" itemvalue="detectron2" />
|
| 69 |
+
</list>
|
| 70 |
+
</value>
|
| 71 |
+
</option>
|
| 72 |
+
</inspection_tool>
|
| 73 |
+
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
| 74 |
+
<option name="ignoredIdentifiers">
|
| 75 |
+
<list>
|
| 76 |
+
<option value="super.on_epoch_end" />
|
| 77 |
+
<option value="adhoc.demos.face_mesh_comparison.torch" />
|
| 78 |
+
<option value="pipeline.entities.Annotation.__getitem__" />
|
| 79 |
+
</list>
|
| 80 |
+
</option>
|
| 81 |
+
</inspection_tool>
|
| 82 |
+
</profile>
|
| 83 |
+
</component>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<component name="InspectionProjectProfileManager">
|
| 2 |
+
<settings>
|
| 3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
| 4 |
+
<version value="1.0" />
|
| 5 |
+
</settings>
|
| 6 |
+
</component>
|
.idea/modules.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="ProjectModuleManager">
|
| 4 |
+
<modules>
|
| 5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/vgg_heads.iml" filepath="$PROJECT_DIR$/.idea/vgg_heads.iml" />
|
| 6 |
+
</modules>
|
| 7 |
+
</component>
|
| 8 |
+
</project>
|
.idea/vcs.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="VcsDirectoryMappings">
|
| 4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
| 5 |
+
</component>
|
| 6 |
+
</project>
|
.idea/vgg_heads.iml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<module type="PYTHON_MODULE" version="4">
|
| 3 |
+
<component name="NewModuleRootManager">
|
| 4 |
+
<content url="file://$MODULE_DIR$" />
|
| 5 |
+
<orderEntry type="inheritedJdk" />
|
| 6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
| 7 |
+
</component>
|
| 8 |
+
</module>
|
app.py
CHANGED
|
@@ -1,146 +1,30 @@
|
|
| 1 |
-
import
|
| 2 |
-
import numpy as np
|
| 3 |
-
import random
|
| 4 |
-
from diffusers import DiffusionPipeline
|
| 5 |
-
import torch
|
| 6 |
-
|
| 7 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
pipe.enable_xformers_memory_efficient_attention()
|
| 13 |
-
pipe = pipe.to(device)
|
| 14 |
-
else:
|
| 15 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
|
| 16 |
-
pipe = pipe.to(device)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
MAX_IMAGE_SIZE = 1024
|
| 20 |
|
| 21 |
-
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
generator = torch.Generator().manual_seed(seed)
|
| 27 |
-
|
| 28 |
-
image = pipe(
|
| 29 |
-
prompt = prompt,
|
| 30 |
-
negative_prompt = negative_prompt,
|
| 31 |
-
guidance_scale = guidance_scale,
|
| 32 |
-
num_inference_steps = num_inference_steps,
|
| 33 |
-
width = width,
|
| 34 |
-
height = height,
|
| 35 |
-
generator = generator
|
| 36 |
-
).images[0]
|
| 37 |
-
|
| 38 |
return image
|
| 39 |
|
| 40 |
-
examples = [
|
| 41 |
-
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
| 42 |
-
"An astronaut riding a green horse",
|
| 43 |
-
"A delicious ceviche cheesecake slice",
|
| 44 |
-
]
|
| 45 |
-
|
| 46 |
-
css="""
|
| 47 |
-
#col-container {
|
| 48 |
-
margin: 0 auto;
|
| 49 |
-
max-width: 520px;
|
| 50 |
-
}
|
| 51 |
-
"""
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
with gr.Blocks(css=css) as demo:
|
| 59 |
-
|
| 60 |
-
with gr.Column(elem_id="col-container"):
|
| 61 |
-
gr.Markdown(f"""
|
| 62 |
-
# Text-to-Image Gradio Template
|
| 63 |
-
Currently running on {power_device}.
|
| 64 |
-
""")
|
| 65 |
-
|
| 66 |
-
with gr.Row():
|
| 67 |
-
|
| 68 |
-
prompt = gr.Text(
|
| 69 |
-
label="Prompt",
|
| 70 |
-
show_label=False,
|
| 71 |
-
max_lines=1,
|
| 72 |
-
placeholder="Enter your prompt",
|
| 73 |
-
container=False,
|
| 74 |
-
)
|
| 75 |
-
|
| 76 |
-
run_button = gr.Button("Run", scale=0)
|
| 77 |
-
|
| 78 |
-
result = gr.Image(label="Result", show_label=False)
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
negative_prompt = gr.Text(
|
| 83 |
-
label="Negative prompt",
|
| 84 |
-
max_lines=1,
|
| 85 |
-
placeholder="Enter a negative prompt",
|
| 86 |
-
visible=False,
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
seed = gr.Slider(
|
| 90 |
-
label="Seed",
|
| 91 |
-
minimum=0,
|
| 92 |
-
maximum=MAX_SEED,
|
| 93 |
-
step=1,
|
| 94 |
-
value=0,
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 98 |
-
|
| 99 |
-
with gr.Row():
|
| 100 |
-
|
| 101 |
-
width = gr.Slider(
|
| 102 |
-
label="Width",
|
| 103 |
-
minimum=256,
|
| 104 |
-
maximum=MAX_IMAGE_SIZE,
|
| 105 |
-
step=32,
|
| 106 |
-
value=512,
|
| 107 |
-
)
|
| 108 |
-
|
| 109 |
-
height = gr.Slider(
|
| 110 |
-
label="Height",
|
| 111 |
-
minimum=256,
|
| 112 |
-
maximum=MAX_IMAGE_SIZE,
|
| 113 |
-
step=32,
|
| 114 |
-
value=512,
|
| 115 |
-
)
|
| 116 |
-
|
| 117 |
-
with gr.Row():
|
| 118 |
-
|
| 119 |
-
guidance_scale = gr.Slider(
|
| 120 |
-
label="Guidance scale",
|
| 121 |
-
minimum=0.0,
|
| 122 |
-
maximum=10.0,
|
| 123 |
-
step=0.1,
|
| 124 |
-
value=0.0,
|
| 125 |
-
)
|
| 126 |
-
|
| 127 |
-
num_inference_steps = gr.Slider(
|
| 128 |
-
label="Number of inference steps",
|
| 129 |
-
minimum=1,
|
| 130 |
-
maximum=12,
|
| 131 |
-
step=1,
|
| 132 |
-
value=2,
|
| 133 |
-
)
|
| 134 |
-
|
| 135 |
-
gr.Examples(
|
| 136 |
-
examples = examples,
|
| 137 |
-
inputs = [prompt]
|
| 138 |
-
)
|
| 139 |
|
| 140 |
-
run_button.click(
|
| 141 |
-
fn = infer,
|
| 142 |
-
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
| 143 |
-
outputs = [result]
|
| 144 |
-
)
|
| 145 |
|
| 146 |
-
|
|
|
|
|
|
| 1 |
+
import uuid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
from fire import Fire
|
| 4 |
+
from head_detector import HeadDetector
|
| 5 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
detector = HeadDetector()
|
|
|
|
| 8 |
|
|
|
|
| 9 |
|
| 10 |
+
def detect_faces(image):
|
| 11 |
+
image = detector(image).draw()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
return image
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=detect_faces,
|
| 17 |
+
inputs=gr.inputs.Image(type="numpy", label="Upload an Image"),
|
| 18 |
+
outputs=gr.outputs.Image(type="numpy", label="Image with Faces"),
|
| 19 |
+
title="Demo of: VGGHeads: A Large-Scale Synthetic Dataset for 3D Human Heads",
|
| 20 |
+
description="Upload an image. The model performs simultaneous heads detection and head meshes reconstruction from a single image in a single step.",
|
| 21 |
+
allow_flagging='never',
|
| 22 |
+
)
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
def main():
|
| 26 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
if __name__ == '__main__':
|
| 30 |
+
Fire(main)
|
requirements.txt
CHANGED
|
@@ -1,6 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
invisible_watermark
|
| 4 |
-
torch
|
| 5 |
-
transformers
|
| 6 |
-
xformers
|
|
|
|
| 1 |
+
git+https://github.com/KupynOrest/head_detector.git
|
| 2 |
+
fire
|
|
|
|
|
|
|
|
|
|
|
|