Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -533,12 +533,20 @@ def generate_video(image, prompt, max_tokens):
|
|
| 533 |
# Dùng multiprocessing
|
| 534 |
# with multiprocessing.Pool(processes=20) as pool:
|
| 535 |
# with ProcessPoolExecutor(max_workers=20) as pool:
|
| 536 |
-
ctx = multiprocessing.get_context()
|
| 537 |
-
ctx.Process(target=lambda: None).daemon = False
|
| 538 |
-
with ctx.Pool(processes=20) as pool:
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 542 |
for i in range(len(text_imgs)):
|
| 543 |
overlay = heatmap_imgs[i]
|
| 544 |
text_img = text_imgs[i]
|
|
@@ -575,7 +583,7 @@ with gr.Blocks() as demo:
|
|
| 575 |
with gr.Column():
|
| 576 |
image = gr.Image(label="Upload your image", type = 'filepath')
|
| 577 |
prompt = gr.Textbox(label="Describe your prompt", value="List all the text." )
|
| 578 |
-
max_tokens = gr.Slider(label="Max token output (⚠️ Choose <100 for faster response)", minimum=1, maximum=
|
| 579 |
btn = gr.Button("Inference")
|
| 580 |
video = gr.Video(label="Visualization Video")
|
| 581 |
|
|
|
|
| 533 |
# Dùng multiprocessing
|
| 534 |
# with multiprocessing.Pool(processes=20) as pool:
|
| 535 |
# with ProcessPoolExecutor(max_workers=20) as pool:
|
| 536 |
+
# ctx = multiprocessing.get_context()
|
| 537 |
+
# ctx.Process(target=lambda: None).daemon = False
|
| 538 |
+
# with ctx.Pool(processes=20) as pool:
|
| 539 |
+
# text_imgs = pool.map(generate_text_img_wrapper, params_for_text)
|
| 540 |
+
# hidden_imgs = pool.map(generate_hidden_img_wrapper, params_for_hidden)
|
| 541 |
+
text_imgs = []
|
| 542 |
+
for param in tqdm.tqdm(params_for_text):
|
| 543 |
+
result = generate_text_img_wrapper(param)
|
| 544 |
+
text_imgs.append(result)
|
| 545 |
+
hidden_imgs = []
|
| 546 |
+
for param in tqdm.tqdm(params_for_hidden):
|
| 547 |
+
result = generate_hidden_img_wrapper(param)
|
| 548 |
+
hidden_imgs.append(result)
|
| 549 |
+
|
| 550 |
for i in range(len(text_imgs)):
|
| 551 |
overlay = heatmap_imgs[i]
|
| 552 |
text_img = text_imgs[i]
|
|
|
|
| 583 |
with gr.Column():
|
| 584 |
image = gr.Image(label="Upload your image", type = 'filepath')
|
| 585 |
prompt = gr.Textbox(label="Describe your prompt", value="List all the text." )
|
| 586 |
+
max_tokens = gr.Slider(label="Max token output (⚠️ Choose <100 for faster response)", minimum=1, maximum=256, value=50)
|
| 587 |
btn = gr.Button("Inference")
|
| 588 |
video = gr.Video(label="Visualization Video")
|
| 589 |
|