Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,7 @@ from model import Model
|
|
| 38 |
model = Model()
|
| 39 |
|
| 40 |
|
| 41 |
-
def controlnet(i, prompt, seed_in):
|
| 42 |
img= Image.open(i)
|
| 43 |
np_img = np.array(img)
|
| 44 |
|
|
@@ -50,11 +50,18 @@ def controlnet(i, prompt, seed_in):
|
|
| 50 |
ddim_steps = 20
|
| 51 |
scale = 9.0
|
| 52 |
eta = 0.0
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
image_resolution, detect_resolution, ddim_steps, scale, seed_in, eta)
|
| 56 |
-
|
| 57 |
-
|
|
|
|
| 58 |
im.save("your_file" + str(i) + ".jpeg")
|
| 59 |
return "your_file" + str(i) + ".jpeg"
|
| 60 |
|
|
@@ -105,7 +112,7 @@ def create_video(frames, fps):
|
|
| 105 |
return 'movie.mp4'
|
| 106 |
|
| 107 |
|
| 108 |
-
def infer(prompt,video_in, seed_in, trim_value):
|
| 109 |
print(f"""
|
| 110 |
βββββββββββββββ
|
| 111 |
{prompt}
|
|
@@ -126,7 +133,7 @@ def infer(prompt,video_in, seed_in, trim_value):
|
|
| 126 |
print("set stop frames to: " + str(n_frame))
|
| 127 |
|
| 128 |
for i in frames_list[0:int(n_frame)]:
|
| 129 |
-
controlnet_img = controlnet(i, prompt, seed_in)
|
| 130 |
#images = controlnet_img[0]
|
| 131 |
#rgb_im = images[0].convert("RGB")
|
| 132 |
|
|
@@ -191,6 +198,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 191 |
with gr.Column():
|
| 192 |
video_inp = gr.Video(label="Video source", source="upload", type="filepath", elem_id="input-vid")
|
| 193 |
prompt = gr.Textbox(label="Prompt", placeholder="enter prompt", show_label=False, elem_id="prompt-in")
|
|
|
|
| 194 |
with gr.Row():
|
| 195 |
seed_inp = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, value=123456)
|
| 196 |
trim_in = gr.Slider(label="Cut video at (s)", minimun=1, maximum=5, step=1, value=1)
|
|
@@ -208,7 +216,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 208 |
loading_icon = gr.HTML(loading_icon_html)
|
| 209 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 210 |
|
| 211 |
-
inputs = [prompt,video_inp,seed_inp, trim_in]
|
| 212 |
outputs = [video_out, share_group]
|
| 213 |
#outputs = [status]
|
| 214 |
|
|
|
|
| 38 |
model = Model()
|
| 39 |
|
| 40 |
|
| 41 |
+
def controlnet(i, prompt, control_task, seed_in):
|
| 42 |
img= Image.open(i)
|
| 43 |
np_img = np.array(img)
|
| 44 |
|
|
|
|
| 50 |
ddim_steps = 20
|
| 51 |
scale = 9.0
|
| 52 |
eta = 0.0
|
| 53 |
+
if control_task == 'Canny':
|
| 54 |
+
result = model.process_canny(np_img, prompt, a_prompt, n_prompt, num_samples,
|
| 55 |
+
image_resolution, detect_resolution, ddim_steps, scale, seed_in, eta)
|
| 56 |
+
elif control_task == 'Depth':
|
| 57 |
+
result = model.process_depth(np_img, prompt, a_prompt, n_prompt, num_samples,
|
| 58 |
+
image_resolution, detect_resolution, ddim_steps, scale, seed_in, eta)
|
| 59 |
+
elif control_task == 'Pose':
|
| 60 |
+
result = model.process_pose(np_img, prompt, a_prompt, n_prompt, num_samples,
|
| 61 |
image_resolution, detect_resolution, ddim_steps, scale, seed_in, eta)
|
| 62 |
+
|
| 63 |
+
#print(result[0])
|
| 64 |
+
im = Image.fromarray(result[1])
|
| 65 |
im.save("your_file" + str(i) + ".jpeg")
|
| 66 |
return "your_file" + str(i) + ".jpeg"
|
| 67 |
|
|
|
|
| 112 |
return 'movie.mp4'
|
| 113 |
|
| 114 |
|
| 115 |
+
def infer(prompt,video_in, control_task, seed_in, trim_value):
|
| 116 |
print(f"""
|
| 117 |
βββββββββββββββ
|
| 118 |
{prompt}
|
|
|
|
| 133 |
print("set stop frames to: " + str(n_frame))
|
| 134 |
|
| 135 |
for i in frames_list[0:int(n_frame)]:
|
| 136 |
+
controlnet_img = controlnet(i, prompt,control_task, seed_in)
|
| 137 |
#images = controlnet_img[0]
|
| 138 |
#rgb_im = images[0].convert("RGB")
|
| 139 |
|
|
|
|
| 198 |
with gr.Column():
|
| 199 |
video_inp = gr.Video(label="Video source", source="upload", type="filepath", elem_id="input-vid")
|
| 200 |
prompt = gr.Textbox(label="Prompt", placeholder="enter prompt", show_label=False, elem_id="prompt-in")
|
| 201 |
+
control_task = gr.Dropdown(["Canny", "Depth", "Pose"], value=["Pose"], multiselect=False),
|
| 202 |
with gr.Row():
|
| 203 |
seed_inp = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, value=123456)
|
| 204 |
trim_in = gr.Slider(label="Cut video at (s)", minimun=1, maximum=5, step=1, value=1)
|
|
|
|
| 216 |
loading_icon = gr.HTML(loading_icon_html)
|
| 217 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 218 |
|
| 219 |
+
inputs = [prompt,video_inp,control_task, seed_inp, trim_in]
|
| 220 |
outputs = [video_out, share_group]
|
| 221 |
#outputs = [status]
|
| 222 |
|