Spaces:
Runtime error
Runtime error
fix
Browse files- app.py +9 -8
- requirements.txt +2 -2
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
|
|
1 |
import torch
|
2 |
from pipelines.inverted_ve_pipeline import STYLE_DESCRIPTION_DICT, create_image_grid
|
3 |
import gradio as gr
|
4 |
-
import os, json
|
5 |
import numpy as np
|
6 |
from PIL import Image
|
7 |
|
@@ -107,12 +108,13 @@ def load_example_controlnet():
|
|
107 |
inf_object_name = config["inference_info"]["inf_object_list"][0]
|
108 |
|
109 |
canny_path = './assets/depth_dir/gundam.png'
|
110 |
-
image_info = [image_path, canny_path, style_name, "", 1, 0.5, 50]
|
111 |
|
112 |
examples.append(image_info)
|
113 |
|
114 |
return examples
|
115 |
|
|
|
116 |
def controlnet_fn(image_path, depth_image_path, style_name, content_text, output_number, controlnet_scale=0.5, diffusion_step=50):
|
117 |
"""
|
118 |
|
@@ -215,7 +217,6 @@ def controlnet_fn(image_path, depth_image_path, style_name, content_text, output
|
|
215 |
# make grid
|
216 |
grid = create_image_grid(images, n_row, n_col)
|
217 |
|
218 |
-
torch.cuda.empty_cache()
|
219 |
return grid
|
220 |
|
221 |
|
@@ -225,16 +226,16 @@ description_md = """
|
|
225 |
### π [[Paper](https://arxiv.org/abs/2402.12974)] | β¨ [[Project page](https://curryjung.github.io/VisualStylePrompt)] | β¨ [[Code](https://github.com/naver-ai/Visual-Style-Prompting)]
|
226 |
### π₯ [[Default ver](https://huggingface.co/spaces/naver-ai/VisualStylePrompting)]
|
227 |
---
|
228 |
-
### Visual Style Prompting also works on `ControlNet` which specifies the shape of the results by depthmap or keypoints.
|
229 |
-
|
230 |
-
### To try out our demo with ControlNet,
|
231 |
1. Upload an `image for depth control`. An off-the-shelf model will produce the depthmap from it.
|
232 |
2. Choose `ControlNet scale` which determines the alignment to the depthmap.
|
233 |
3. Choose a `style reference` from the collection of images below.
|
234 |
4. Enter the `text prompt`. (`Empty text` is okay, but a depthmap description helps.)
|
235 |
5. Choose the `number of outputs`.
|
236 |
|
237 |
-
### To achieve faster results, we recommend lowering the diffusion steps to 30.
|
238 |
### Enjoy ! π
|
239 |
"""
|
240 |
|
@@ -249,7 +250,7 @@ iface_controlnet = gr.Interface(
|
|
249 |
gr.components.Slider(minimum=0.5, maximum=10, step=0.5, value=0.5, label="Controlnet scale"),
|
250 |
gr.components.Slider(minimum=10, maximum=50, step=10, value=50, label="Diffusion steps")
|
251 |
],
|
252 |
-
outputs=gr.components.Image(
|
253 |
title="π¨ Visual Style Prompting (w/ ControlNet)",
|
254 |
description=description_md,
|
255 |
examples=load_example_controlnet(),
|
|
|
1 |
+
import spaces
|
2 |
import torch
|
3 |
from pipelines.inverted_ve_pipeline import STYLE_DESCRIPTION_DICT, create_image_grid
|
4 |
import gradio as gr
|
5 |
+
import os, json
|
6 |
import numpy as np
|
7 |
from PIL import Image
|
8 |
|
|
|
108 |
inf_object_name = config["inference_info"]["inf_object_list"][0]
|
109 |
|
110 |
canny_path = './assets/depth_dir/gundam.png'
|
111 |
+
image_info = [image_path, canny_path, style_name, "", 1, 0.5, 50]
|
112 |
|
113 |
examples.append(image_info)
|
114 |
|
115 |
return examples
|
116 |
|
117 |
+
@spaces.GPU
|
118 |
def controlnet_fn(image_path, depth_image_path, style_name, content_text, output_number, controlnet_scale=0.5, diffusion_step=50):
|
119 |
"""
|
120 |
|
|
|
217 |
# make grid
|
218 |
grid = create_image_grid(images, n_row, n_col)
|
219 |
|
|
|
220 |
return grid
|
221 |
|
222 |
|
|
|
226 |
### π [[Paper](https://arxiv.org/abs/2402.12974)] | β¨ [[Project page](https://curryjung.github.io/VisualStylePrompt)] | β¨ [[Code](https://github.com/naver-ai/Visual-Style-Prompting)]
|
227 |
### π₯ [[Default ver](https://huggingface.co/spaces/naver-ai/VisualStylePrompting)]
|
228 |
---
|
229 |
+
### β¨ Visual Style Prompting also works on `ControlNet` which specifies the shape of the results by depthmap or keypoints.
|
230 |
+
### βΌοΈ w/ ControlNet ver does not support user style images.
|
231 |
+
### π₯ To try out our demo with ControlNet,
|
232 |
1. Upload an `image for depth control`. An off-the-shelf model will produce the depthmap from it.
|
233 |
2. Choose `ControlNet scale` which determines the alignment to the depthmap.
|
234 |
3. Choose a `style reference` from the collection of images below.
|
235 |
4. Enter the `text prompt`. (`Empty text` is okay, but a depthmap description helps.)
|
236 |
5. Choose the `number of outputs`.
|
237 |
|
238 |
+
### π To achieve faster results, we recommend lowering the diffusion steps to 30.
|
239 |
### Enjoy ! π
|
240 |
"""
|
241 |
|
|
|
250 |
gr.components.Slider(minimum=0.5, maximum=10, step=0.5, value=0.5, label="Controlnet scale"),
|
251 |
gr.components.Slider(minimum=10, maximum=50, step=10, value=50, label="Diffusion steps")
|
252 |
],
|
253 |
+
outputs=gr.components.Image(label="Generated Image"),
|
254 |
title="π¨ Visual Style Prompting (w/ ControlNet)",
|
255 |
description=description_md,
|
256 |
examples=load_example_controlnet(),
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
torch
|
2 |
diffusers
|
3 |
transformers
|
4 |
accelerate
|
@@ -8,5 +8,5 @@ gradio
|
|
8 |
triton
|
9 |
torchvision
|
10 |
opencv-python
|
11 |
-
xformers
|
12 |
|
|
|
1 |
+
torch
|
2 |
diffusers
|
3 |
transformers
|
4 |
accelerate
|
|
|
8 |
triton
|
9 |
torchvision
|
10 |
opencv-python
|
11 |
+
xformers
|
12 |
|