Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -166,6 +166,43 @@ def reload_javascript():
|
|
166 |
|
167 |
GradioTemplateResponseOriginal = gr.routes.templates.TemplateResponse
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
if __name__ == '__main__':
|
171 |
reload_javascript()
|
@@ -181,8 +218,13 @@ if __name__ == '__main__':
|
|
181 |
xpath = os.path.join(project_dir,"javascript/lazyload/posex-webui.js")
|
182 |
js_ = [project_dir, f'{xpath}?{os.path.getmtime(xpath)}']
|
183 |
print(js_)
|
|
|
184 |
with gr.Blocks() as demo:
|
|
|
|
|
185 |
with gr.Tab("sketch"):
|
|
|
|
|
186 |
with gr.Row():
|
187 |
image_prompt_sketch = gr.Textbox(label="image prompt", value='', elem_id=id('image_prompt'))
|
188 |
image_n_prompt_sketch = gr.Textbox(label="negative prompt", value='',
|
@@ -197,6 +239,8 @@ if __name__ == '__main__':
|
|
197 |
outputs=[result_img])
|
198 |
|
199 |
with gr.Tab("openpose", elem_id=id('tab')):
|
|
|
|
|
200 |
# with gr.Row():
|
201 |
# enabled = gr.Checkbox(value=False, label='Send this image to ControlNet.', elem_id=id('enabled'))
|
202 |
# cn_num = gr.Number(value=0, precision=0, label='Target ControlNet number', visible=True)
|
|
|
166 |
|
167 |
GradioTemplateResponseOriginal = gr.routes.templates.TemplateResponse
|
168 |
|
169 |
+
introduce = """
|
170 |
+
# ControlnetWithBackground
|
171 |
+
### Controlnet
|
172 |
+
### Inpainting
|
173 |
+
### Stable diffusion
|
174 |
+
|
175 |
+
Use controlnet to generate sketches and characters, and keep the background unchanged.
|
176 |
+
|
177 |
+
Usually when we generate a very perfect background image, we want to add image elements, but using controlnet directly will affect the original background. This project aims to add elements to the page while keeping the background unchanged, and can directly operate on the original background.
|
178 |
+
|
179 |
+
Support skeletal character generation and sketch generation.
|
180 |
+
|
181 |
+
Optimize an inpaint model for the general domain against the stablediffusion-inpaint model.
|
182 |
+
|
183 |
+
### Two modes, openpose control and manuscript control
|
184 |
+
#### openpose control
|
185 |
+
#### manuscript control
|
186 |
+
|
187 |
+
"""
|
188 |
+
|
189 |
+
openpose_intro = """
|
190 |
+
Add character skeletons to a forest scene generated by SD, and keep the background unchanged to generate controllable characters
|
191 |
+
<img src="https://huggingface.co/spaces/hirol/ControlnetWithBackground/resolve/main/person.png" width="400" height="300">
|
192 |
+
<video width="320" height="240" controls>
|
193 |
+
<source src="https://huggingface.co/spaces/hirol/ControlnetWithBackground/resolve/main/person_control.mp4" type="video/mp4">
|
194 |
+
</video>
|
195 |
+
"""
|
196 |
+
|
197 |
+
manuscript_intro = """
|
198 |
+
Added manuscript houses to an SD generated forest scene
|
199 |
+
<img src="https://huggingface.co/spaces/hirol/ControlnetWithBackground/resolve/main/house.png" width="600" height="300">
|
200 |
+
<video width="320" height="240" controls>
|
201 |
+
<source src="https://huggingface.co/spaces/hirol/ControlnetWithBackground/resolve/main/house.mp4" type="video/mp4">
|
202 |
+
</video>
|
203 |
+
Added manuscript chairs to an SD generated snow scene
|
204 |
+
<img src="https://huggingface.co/spaces/hirol/ControlnetWithBackground/resolve/main/chair.png" width="600" height="300">
|
205 |
+
"""
|
206 |
|
207 |
if __name__ == '__main__':
|
208 |
reload_javascript()
|
|
|
218 |
xpath = os.path.join(project_dir,"javascript/lazyload/posex-webui.js")
|
219 |
js_ = [project_dir, f'{xpath}?{os.path.getmtime(xpath)}']
|
220 |
print(js_)
|
221 |
+
|
222 |
with gr.Blocks() as demo:
|
223 |
+
with gr.Row():
|
224 |
+
gr.Markdown(introduce)
|
225 |
with gr.Tab("sketch"):
|
226 |
+
with gr.Row():
|
227 |
+
gr.Markdown(manuscript_intro)
|
228 |
with gr.Row():
|
229 |
image_prompt_sketch = gr.Textbox(label="image prompt", value='', elem_id=id('image_prompt'))
|
230 |
image_n_prompt_sketch = gr.Textbox(label="negative prompt", value='',
|
|
|
239 |
outputs=[result_img])
|
240 |
|
241 |
with gr.Tab("openpose", elem_id=id('tab')):
|
242 |
+
with gr.Row():
|
243 |
+
gr.Markdown(openpose_intro)
|
244 |
# with gr.Row():
|
245 |
# enabled = gr.Checkbox(value=False, label='Send this image to ControlNet.', elem_id=id('enabled'))
|
246 |
# cn_num = gr.Number(value=0, precision=0, label='Target ControlNet number', visible=True)
|