forked from openvinotoolkit/openvino_notebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gradio helpers - part 5 (openvinotoolkit#2323)
Ticket: CVS-147626 Notebooks: 1. film-slowmo/film-slowmo.ipynb 2. freevc-voice-conversion/freevc-voice-conversion.ipynb 3. grammar-correction/grammar-correction.ipynb 4. hunyuan-dit-image-generation/hunyuan-dit-image-generation.ipynb 5. instant-id/instant-id.ipynb 6. instruct-pix2pix-image-editing/instruct-pix2pix-image-editing.ipynb 7. kosmos2-multimodal-large-language-model/kosmos2-multimodal-large-language-model.ipynb 8. latent-consistency-models-image-generation/latent-consistency-models-image-generation.ipynb 9. latent-consistency-models-image-generation/lcm-lora-controlnet.ipynb 10. llava-multimodal-chatbot/llava-multimodal-chatbot.ipynb 11. llava-multimodal-chatbot/videollava-multimodal-chatbot.ipynb 12. llava-next-multimodal-chatbot/llava-next-multimodal-chatbot.ipynb
- Loading branch information
Showing
22 changed files
with
1,053 additions
and
735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Callable | ||
import gradio as gr | ||
|
||
examples = [["data/one.jpg", "data/two.jpg", 5]] | ||
|
||
|
||
def make_demo(fn: Callable): | ||
demo = gr.Interface( | ||
fn=fn, | ||
inputs=[ | ||
gr.Image(label="First image"), | ||
gr.Image(label="Last image"), | ||
gr.Slider( | ||
1, | ||
8, | ||
step=1, | ||
label="Times to interpolate", | ||
info="""Controls the number of times the frame interpolator is invoked. | ||
The output will be the interpolation video with (2^value + 1) frames, fps of 30.""", | ||
), | ||
], | ||
outputs=gr.Video(), | ||
examples=examples, | ||
allow_flagging="never", | ||
) | ||
return demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Callable | ||
import gradio as gr | ||
|
||
|
||
def make_demo(fn: Callable): | ||
audio1 = gr.Audio(label="Source Audio", type="filepath") | ||
audio2 = gr.Audio(label="Reference Audio", type="filepath") | ||
outputs = gr.Audio(label="Output Audio", type="filepath") | ||
examples = [["p225_001.wav", "p226_002.wav"]] | ||
|
||
title = "FreeVC with Gradio" | ||
description = 'Gradio Demo for FreeVC and OpenVINO™. Upload a source audio and a reference audio, then click the "Submit" button to inference.' | ||
|
||
demo = gr.Interface( | ||
fn=fn, | ||
inputs=[audio1, audio2], | ||
outputs=outputs, | ||
title=title, | ||
description=description, | ||
examples=examples, | ||
) | ||
return demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Callable | ||
import gradio as gr | ||
from functools import partial | ||
|
||
default_text = ( | ||
"Most of the course is about semantic or content of language but there are also interesting" | ||
" topics to be learned from the servicefeatures except statistics in characters in documents.At" | ||
" this point, He introduces herself as his native English speaker and goes on to say that if" | ||
" you contine to work on social scnce" | ||
) | ||
|
||
|
||
def make_demo(fn: Callable, quantized: bool): | ||
model_type = "optimized" if quantized else "original" | ||
with gr.Blocks() as demo: | ||
gr.Markdown("# Interactive demo") | ||
with gr.Row(): | ||
gr.Markdown(f"## Run {model_type} grammar correction pipeline") | ||
with gr.Row(): | ||
with gr.Column(): | ||
input_text = gr.Textbox(label="Text") | ||
with gr.Column(): | ||
output_text = gr.Textbox(label="Correction", interactive=False, show_copy_button=True) | ||
correction_time = gr.Textbox(label="Time (seconds)", interactive=False) | ||
with gr.Row(): | ||
gr.Examples(examples=[default_text], inputs=[input_text]) | ||
with gr.Row(): | ||
button = gr.Button(f"Run {model_type}") | ||
button.click( | ||
fn=partial(fn, quantized=quantized), | ||
inputs=[input_text, gr.Number(quantized, visible=False)], | ||
outputs=[output_text, correction_time], | ||
) | ||
return demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from typing import Callable | ||
import gradio as gr | ||
from hydit.constants import NEGATIVE_PROMPT | ||
|
||
examples = [ | ||
["一只小猫"], | ||
["a kitten"], | ||
["一只聪明的狐狸走在阔叶树林里, 旁边是一条小溪, 细节真实, 摄影"], | ||
["A clever fox walks in a broadleaf forest next to a stream, realistic details, photography"], | ||
["请将“杞人忧天”的样子画出来"], | ||
['Please draw a picture of "unfounded worries"'], | ||
["枯藤老树昏鸦,小桥流水人家"], | ||
["Withered vines, old trees and dim crows, small bridges and flowing water, people's houses"], | ||
["湖水清澈,天空湛蓝,阳光灿烂。一只优雅的白天鹅在湖边游泳。它周围有几只小鸭子,看起来非常可爱,整个画面给人一种宁静祥和的感觉。"], | ||
[ | ||
"The lake is clear, the sky is blue, and the sun is bright. An elegant white swan swims by the lake. There are several little ducks around it, which look very cute, and the whole picture gives people a sense of peace and tranquility." | ||
], | ||
["一朵鲜艳的红色玫瑰花,花瓣撒有一些水珠,晶莹剔透,特写镜头"], | ||
["A bright red rose flower with petals sprinkled with some water drops, crystal clear, close-up"], | ||
["风格是写实,画面主要描述一个亚洲戏曲艺术家正在表演,她穿着华丽的戏服,脸上戴着精致的面具,身姿优雅,背景是古色古香的舞台,镜头是近景"], | ||
[ | ||
"The style is realistic. The picture mainly depicts an Asian opera artist performing. She is wearing a gorgeous costume and a delicate mask on her face. Her posture is elegant. The background is an antique stage and the camera is a close-up." | ||
], | ||
] | ||
|
||
|
||
def make_demo(fn: Callable): | ||
with gr.Blocks() as demo: | ||
with gr.Row(): | ||
with gr.Column(): | ||
prompt = gr.Textbox(label="Input prompt", lines=3) | ||
with gr.Row(): | ||
infer_steps = gr.Slider( | ||
label="Number Inference steps", | ||
minimum=1, | ||
maximum=200, | ||
value=15, | ||
step=1, | ||
) | ||
seed = gr.Number( | ||
label="Seed", | ||
minimum=-1, | ||
maximum=1_000_000_000, | ||
value=42, | ||
step=1, | ||
precision=0, | ||
) | ||
with gr.Accordion("Advanced settings", open=False): | ||
with gr.Row(): | ||
negative_prompt = gr.Textbox( | ||
label="Negative prompt", | ||
value=NEGATIVE_PROMPT, | ||
lines=2, | ||
) | ||
with gr.Row(): | ||
oriW = gr.Number( | ||
label="Width", | ||
minimum=768, | ||
maximum=1024, | ||
value=880, | ||
step=16, | ||
precision=0, | ||
min_width=80, | ||
) | ||
oriH = gr.Number( | ||
label="Height", | ||
minimum=768, | ||
maximum=1024, | ||
value=880, | ||
step=16, | ||
precision=0, | ||
min_width=80, | ||
) | ||
cfg_scale = gr.Slider(label="Guidance scale", minimum=1.0, maximum=16.0, value=7.5, step=0.5) | ||
with gr.Row(): | ||
advanced_button = gr.Button() | ||
with gr.Column(): | ||
output_img = gr.Image( | ||
label="Generated image", | ||
interactive=False, | ||
) | ||
advanced_button.click( | ||
fn=fn, | ||
inputs=[ | ||
prompt, | ||
negative_prompt, | ||
seed, | ||
infer_steps, | ||
oriH, | ||
oriW, | ||
], | ||
outputs=output_img, | ||
) | ||
|
||
with gr.Row(): | ||
gr.Examples(examples=examples, inputs=[prompt]) | ||
return demo |
Oops, something went wrong.