From cc9a585bbea53725e26e3d3b37a5bd6aa79d6b2d Mon Sep 17 00:00:00 2001 From: pramitchoudhary Date: Mon, 31 Oct 2022 15:58:09 -0700 Subject: [PATCH] Enable upload n capture for Prompt option #5 --- img_styler/ui/common.py | 8 +++++--- img_styler/ui/components.py | 41 +++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/img_styler/ui/common.py b/img_styler/ui/common.py index 56b1149..e6805e0 100644 --- a/img_styler/ui/common.py +++ b/img_styler/ui/common.py @@ -1,8 +1,10 @@ import base64 import os import random + from h2o_wave import Q, ui +from ..utils.dataops import img2buf from .components import ( get_controls, get_footer, @@ -13,9 +15,8 @@ get_processed_face_card, get_source_face_card, get_style_face_card, - get_user_title, + get_user_title ) -from ..utils.dataops import img2buf async def update_faces(q: Q, save=False): @@ -28,12 +29,13 @@ async def update_faces(q: Q, save=False): img2buf(q.client.source_face), type='jpg' ) else: + txt_val = q.client.prompt_textbox if q.client.prompt_textbox else '' q.page['source_face'] = get_source_face_card( img2buf(q.client.source_face), type='jpg', height='520px', width='500px' ) if q.client.task_choice == 'C': q.page['prompt_form'] = ui.form_card(ui.box('main', order=1, height='200px', width='900px'), items=[ - ui.textbox(name='prompt_textbox', label='Prompt', multiline=True, value=q.client.prompt_textbox), + ui.copyable_text(name='prompt_textbox', label='Prompt (Express your creativity)', multiline=True, value=txt_val), ui.button(name='prompt_apply', label='Apply')]) del q.page['style_face'] diff --git a/img_styler/ui/components.py b/img_styler/ui/components.py index 608c00a..d989b18 100644 --- a/img_styler/ui/components.py +++ b/img_styler/ui/components.py @@ -385,12 +385,45 @@ def get_controls(q: Q): required=True, trigger=True, choices=task_choices, - tooltip="There are 2 options available. \ + tooltip="There are few options available. \ Image Styling (Transfer a style to an original image) and \ - Image Editing (Edit and transform an existing image).", + Image Editing (Edit and transform an existing image).,\ + Image Prompt (Generate image via prompt)." ), - ui.checkbox(name='checkbox_without_training', label='Without re-training', value=True), - ui.checkbox(name='checkbox_re_training', label='Dreambooth fine-tuning')]) + ui.dropdown( + name='source_face', + label='Source Face', + choices=[ + ui.choice(name=x, label=os.path.basename(x)) + for x in q.app.source_faces + ], + value=q.client.source_face, + trigger=True, + tooltip='Select a source face for editing. One can upload a new source face as well.', + ), + ui.buttons( + [ + ui.button( + name='upload_image_dialog', + label='Upload', + primary=True, + tooltip='Upload an image.', + ), + ui.button( + name='#capture', + label='Capture', + primary=True, + tooltip='Upload an image using the camera.', + ), + ], + justify='end', + ), + ui.choice_group(name='choice_group_prompt', label='Options', value='checkbox_without_training', + choices=[ + ui.choice(name='checkbox_without_training', label='Default diffusion'), + ui.choice(name='checkbox_re_training', label='Dreambooth fine-tuning', disabled=True) + ]) + ]) def get_source_header():