Spaces:
Build error
Build error
added/updated app files
Browse files- app.py +27 -19
- favicon.ico +0 -0
- modules/engine_inpaint.py +13 -4
- modules/service_configs.py +43 -11
app.py
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
import gradio as ui; from modules.engine_inpaint import *
|
2 |
feature = 'Image Inpainting'
|
3 |
'''
|
4 |
-
_______ _______ _______ _____ _____ _______ __
|
5 |
-
| __||_ _|| ___|| |_ | |_ | _ | .---.-.|__|
|
6 |
-
|__ | | | | ___|| || || | __ | _ || |
|
7 |
-
|_______| |___| |_______||_______||_______||___|___||__||___._||__|
|
8 |
_____________________________________________________________________
|
9 |
|
10 |
Copyright © 2023-2024 Ikmal Said. All rights reserved.
|
@@ -16,22 +12,34 @@ _____________________________________________________________________
|
|
16 |
|
17 |
'''
|
18 |
with ui.Blocks(css=css, title=title(feature), theme=theme, analytics_enabled=False) as stella:
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
prompt_example = ui.Examples(label="Suggested for you:", examples=['highly detailed face', 'detailed girl face', 'detailed man face', 'detailed hand', 'detailed leg', 'beautiful eyes'], inputs=[prompt_inpaint])
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
if __name__ == "__main__":
|
37 |
-
stella.queue(default_concurrency_limit=100, api_open=True).launch(inbrowser=True)
|
|
|
1 |
import gradio as ui; from modules.engine_inpaint import *
|
2 |
feature = 'Image Inpainting'
|
3 |
'''
|
|
|
|
|
|
|
|
|
4 |
_____________________________________________________________________
|
5 |
|
6 |
Copyright © 2023-2024 Ikmal Said. All rights reserved.
|
|
|
12 |
|
13 |
'''
|
14 |
with ui.Blocks(css=css, title=title(feature), theme=theme, analytics_enabled=False) as stella:
|
15 |
+
with ui.Tabs() as tabs_inpaint:
|
16 |
+
with ui.TabItem(title(feature), id=0):
|
17 |
+
with ui.Group():
|
18 |
+
input_inpaint = ui.ImageEditor(
|
19 |
+
show_label=False, transforms=[],
|
20 |
+
brush=ui.Brush(default_size=24, colors=['#ffffff'], color_mode=['fixed']),
|
21 |
+
eraser=ui.Eraser(default_size=24), sources=['upload', 'webcam'])
|
|
|
22 |
|
23 |
+
prompt_inpaint = ui.Textbox(label="What to include:", show_copy_button=True, placeholder=spholder1)
|
24 |
+
|
25 |
+
with ui.Row():
|
26 |
+
submit_inpaint = ui.Button("Submit", variant="primary")
|
27 |
|
28 |
+
prompt_example = ui.Examples(label="AI Enhance keywords:", examples=['highly detailed face', 'detailed girl face', 'detailed man face', 'detailed hand', 'detailed leg', 'beautiful eyes'], inputs=[prompt_inpaint])
|
29 |
+
with ui.Accordion('Advanced', open=False):
|
30 |
+
negative_inpaint = ui.Textbox(label="What not to include:", show_copy_button=True, placeholder=spholder2)
|
31 |
+
number_inpaint = ui.Dropdown(label=snumber, choices=[1,2,3,4], value=4, filterable=False)
|
32 |
+
|
33 |
+
with ui.TabItem('Result', id=1):
|
34 |
+
with ui.Group():
|
35 |
+
output_inpaint = ui.Gallery(preview=True, show_label=False, object_fit="contain", height="43.4vh", show_share_button=False)
|
36 |
+
|
37 |
+
with ui.Row():
|
38 |
+
clear_inpaint = ui.ClearButton(value="Reset", components=[input_inpaint, output_inpaint, prompt_inpaint, negative_inpaint])
|
39 |
+
|
40 |
+
process_inpaint = submit_inpaint.click(fn=inpaint2, inputs=[input_inpaint, prompt_inpaint, negative_inpaint, number_inpaint], outputs=[tabs_inpaint, input_inpaint, output_inpaint])
|
41 |
+
prompt_inpaint.submit(fn=inpaint2, inputs=[input_inpaint, prompt_inpaint, negative_inpaint, number_inpaint], outputs=[tabs_inpaint, input_inpaint, output_inpaint])
|
42 |
+
clear_inpaint.click(fn=reset, inputs=None, outputs=tabs_inpaint)
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
+
stella.queue(default_concurrency_limit=100, api_open=True).launch(inbrowser=True, favicon_path="favicon.ico")
|
favicon.ico
ADDED
modules/engine_inpaint.py
CHANGED
@@ -26,7 +26,7 @@ def inpaint(input_image, input_mask, prompt, negative):
|
|
26 |
payload = {
|
27 |
'model_version': (None, '1'),
|
28 |
'prompt': (None, prompt),
|
29 |
-
'neg_prompt': (None, negative),
|
30 |
'inpaint_strength': (None, '0.75'),
|
31 |
'cfg': (None, '9.5'),
|
32 |
'priority': (None, '1'),
|
@@ -51,6 +51,11 @@ def inpaint(input_image, input_mask, prompt, negative):
|
|
51 |
print(timeout())
|
52 |
return None
|
53 |
|
|
|
|
|
|
|
|
|
|
|
54 |
###################################################################################################################
|
55 |
# 4 image for each generation
|
56 |
###################################################################################################################
|
@@ -82,7 +87,11 @@ def quads_inpaint(a, b, c, d, progress=ui.Progress()):
|
|
82 |
ui.Warning(message=single_error)
|
83 |
else:
|
84 |
ui.Warning(message=quads_error)
|
85 |
-
else:
|
86 |
-
ui.Info(message=success)
|
87 |
|
88 |
-
return successful_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
payload = {
|
27 |
'model_version': (None, '1'),
|
28 |
'prompt': (None, prompt),
|
29 |
+
'neg_prompt': (None, f"({negative}), hands, face, eyes, legs"),
|
30 |
'inpaint_strength': (None, '0.75'),
|
31 |
'cfg': (None, '9.5'),
|
32 |
'priority': (None, '1'),
|
|
|
51 |
print(timeout())
|
52 |
return None
|
53 |
|
54 |
+
except Exception as e:
|
55 |
+
print(f"An error occurred: {e}")
|
56 |
+
ui.Warning(message=single_error)
|
57 |
+
return None
|
58 |
+
|
59 |
###################################################################################################################
|
60 |
# 4 image for each generation
|
61 |
###################################################################################################################
|
|
|
87 |
ui.Warning(message=single_error)
|
88 |
else:
|
89 |
ui.Warning(message=quads_error)
|
|
|
|
|
90 |
|
91 |
+
return successful_results
|
92 |
+
|
93 |
+
def inpaint2(a, b, c, d):
|
94 |
+
return ui.Tabs(selected=1), a, quads_inpaint(a, b, c, d)
|
95 |
+
|
96 |
+
def reset():
|
97 |
+
return ui.Tabs(selected=0)
|
modules/service_configs.py
CHANGED
@@ -4,25 +4,60 @@ import gradio as ui; from datetime import datetime; import logging
|
|
4 |
logging.basicConfig(level=logging.DEBUG)
|
5 |
|
6 |
# global theme
|
7 |
-
theme = ui.themes.
|
8 |
-
font=[ui.themes.GoogleFont('
|
9 |
-
text_size=ui.themes.Size(lg="
|
10 |
-
primary_hue='rose', secondary_hue='rose', neutral_hue='zinc'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# global locale - english
|
13 |
success = 'That worked successfully!'
|
14 |
-
single_error = 'That did not work
|
15 |
-
quads_error = 'Some images cannot be processed
|
|
|
16 |
received = 'Request Received'
|
17 |
timed = 'Request Timeout'
|
18 |
rejected = 'Request Error/Rejected'
|
19 |
complete = 'Request Completed'
|
20 |
liability = 'STELLA can make mistakes and inaccuracies.'
|
21 |
rights = '© 2023-2024 Ikmal Said. All rights reserved.'
|
22 |
-
spholder = 'Imagine
|
23 |
spholder1 = 'Elements to add into the image!'
|
24 |
spholder2 = 'Things to get rid of!'
|
25 |
-
spholder3 = '
|
26 |
sprompt = 'Generate images of:'
|
27 |
sprompt1 = 'Based on image, create:'
|
28 |
smodel = 'Using the AI model:'
|
@@ -31,9 +66,6 @@ sratio = 'In the size of:'
|
|
31 |
sstyle = 'Inspired by the style of:'
|
32 |
squality = 'At a quality level of:'
|
33 |
snumber = 'With a quantity of:'
|
34 |
-
ssource = 'Source'
|
35 |
-
sresult = 'Result'
|
36 |
-
sresults = 'Results'
|
37 |
|
38 |
# global function
|
39 |
def timestamp(): return f"[{datetime.now().strftime('%d/%m/%y at %H:%M:%S')}]"
|
|
|
4 |
logging.basicConfig(level=logging.DEBUG)
|
5 |
|
6 |
# global theme
|
7 |
+
theme = ui.themes.Default(
|
8 |
+
font=[ui.themes.GoogleFont('Roboto Condensed'), 'Arial'],
|
9 |
+
text_size=ui.themes.Size(lg="16px", md="16px", sm="16px", xl="16px", xs="16px", xxl="16px", xxs="16px"),
|
10 |
+
primary_hue='rose', secondary_hue='rose', neutral_hue='zinc', radius_size=ui.themes.sizes.radius_none)
|
11 |
+
|
12 |
+
css = '''
|
13 |
+
footer {
|
14 |
+
display: none !important;
|
15 |
+
}
|
16 |
+
|
17 |
+
div.svelte-vt1mxs>*, div.svelte-vt1mxs>.form > * {
|
18 |
+
border: none;
|
19 |
+
}
|
20 |
+
|
21 |
+
.app.svelte-182fdeq.svelte-182fdeq {
|
22 |
+
padding: 0px !important;
|
23 |
+
}
|
24 |
+
|
25 |
+
.grid-wrap.svelte-hpz95u.svelte-hpz95u {
|
26 |
+
overflow-y: auto !important;
|
27 |
+
}
|
28 |
+
|
29 |
+
.selected.svelte-1uw5tnk {
|
30 |
+
background: #262629 !important;
|
31 |
+
}
|
32 |
+
|
33 |
+
.closed.svelte-g7pfx4>button.svelte-g7pfx4 {
|
34 |
+
display: none !important;
|
35 |
+
}
|
36 |
+
|
37 |
+
gradio-app {
|
38 |
+
background: none !important;
|
39 |
+
}
|
40 |
+
|
41 |
+
input.svelte-1f354aw.svelte-1f354aw, textarea.svelte-1f354aw.svelte-1f354aw {
|
42 |
+
text-align: justify !important;
|
43 |
+
}
|
44 |
+
'''
|
45 |
|
46 |
# global locale - english
|
47 |
success = 'That worked successfully!'
|
48 |
+
single_error = 'That did not work!'
|
49 |
+
quads_error = 'Some images cannot be processed!'
|
50 |
+
empty_error = 'Prompt field cannot be empty!'
|
51 |
received = 'Request Received'
|
52 |
timed = 'Request Timeout'
|
53 |
rejected = 'Request Error/Rejected'
|
54 |
complete = 'Request Completed'
|
55 |
liability = 'STELLA can make mistakes and inaccuracies.'
|
56 |
rights = '© 2023-2024 Ikmal Said. All rights reserved.'
|
57 |
+
spholder = 'Imagine a person, place or anything!'
|
58 |
spholder1 = 'Elements to add into the image!'
|
59 |
spholder2 = 'Things to get rid of!'
|
60 |
+
spholder3 = 'Put wonders into the generated prompt!'
|
61 |
sprompt = 'Generate images of:'
|
62 |
sprompt1 = 'Based on image, create:'
|
63 |
smodel = 'Using the AI model:'
|
|
|
66 |
sstyle = 'Inspired by the style of:'
|
67 |
squality = 'At a quality level of:'
|
68 |
snumber = 'With a quantity of:'
|
|
|
|
|
|
|
69 |
|
70 |
# global function
|
71 |
def timestamp(): return f"[{datetime.now().strftime('%d/%m/%y at %H:%M:%S')}]"
|