Skip to content

Commit

Permalink
Enable upload n capture for Prompt option #5
Browse files Browse the repository at this point in the history
  • Loading branch information
pramitchoudhary committed Oct 31, 2022
1 parent 1387a24 commit 08b6f40
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
8 changes: 5 additions & 3 deletions img_styler/ui/common.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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):
Expand All @@ -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']
Expand Down
41 changes: 37 additions & 4 deletions img_styler/ui/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,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.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.checkbox(name='checkbox_without_training', label='Without re-training', value=True),
ui.checkbox(name='checkbox_re_training', label='Dreambooth fine-tuning')])
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():
Expand Down

0 comments on commit 08b6f40

Please sign in to comment.