Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -75,9 +75,13 @@ app.layout = dbc.Container([
|
|
75 |
]),
|
76 |
dbc.Row([
|
77 |
dbc.Col([
|
78 |
-
html.H4("Original Image", className="mt-4"),
|
79 |
dbc.Button("Upscale Image", id="upscale-button", color="primary", className="mb-3"),
|
80 |
-
html.Div(id=
|
|
|
|
|
|
|
|
|
|
|
81 |
dbc.Card(id='output-image-upload', body=True)
|
82 |
], md=12, lg=6),
|
83 |
dbc.Col([
|
@@ -102,30 +106,19 @@ def update_output(contents, filename):
|
|
102 |
])
|
103 |
|
104 |
@app.callback(
|
105 |
-
[Output('
|
106 |
-
Output('
|
107 |
-
Output('
|
108 |
Input('upscale-button', 'n_clicks'),
|
109 |
State('upload-image', 'contents'),
|
110 |
prevent_initial_call=True
|
111 |
)
|
112 |
def upscale_image_callback(n_clicks, contents):
|
113 |
if contents is None:
|
114 |
-
return
|
115 |
-
|
116 |
-
status_div = html.Div([
|
117 |
-
dbc.Spinner(size="sm", color="primary", type="grow"),
|
118 |
-
html.Span(" Upscaling image... ", style={'marginLeft': '10px'}),
|
119 |
-
html.Div(className="pulsing-dot d-inline-block")
|
120 |
-
])
|
121 |
|
122 |
def upscale_thread():
|
123 |
-
|
124 |
-
success = upscale_image(contents)
|
125 |
-
if success:
|
126 |
-
status_div = "Upscaling complete!"
|
127 |
-
else:
|
128 |
-
status_div = "Upscaling failed. Please try again."
|
129 |
|
130 |
threading.Thread(target=upscale_thread).start()
|
131 |
|
@@ -136,9 +129,9 @@ def upscale_image_callback(n_clicks, contents):
|
|
136 |
upscaled_image = html.Div([
|
137 |
html.Img(src=f"data:image/png;base64,{base64.b64encode(generated_file).decode()}", style={'width': '100%'})
|
138 |
])
|
139 |
-
return
|
140 |
else:
|
141 |
-
return
|
142 |
|
143 |
@app.callback(
|
144 |
Output("download-image", "data"),
|
|
|
75 |
]),
|
76 |
dbc.Row([
|
77 |
dbc.Col([
|
|
|
78 |
dbc.Button("Upscale Image", id="upscale-button", color="primary", className="mb-3"),
|
79 |
+
dbc.Spinner(html.Div(id="loading-output"), color="primary", type="border", size="sm"),
|
80 |
+
], width=12, className="text-center"),
|
81 |
+
]),
|
82 |
+
dbc.Row([
|
83 |
+
dbc.Col([
|
84 |
+
html.H4("Original Image", className="mt-4"),
|
85 |
dbc.Card(id='output-image-upload', body=True)
|
86 |
], md=12, lg=6),
|
87 |
dbc.Col([
|
|
|
106 |
])
|
107 |
|
108 |
@app.callback(
|
109 |
+
[Output('output-upscaled-image', 'children'),
|
110 |
+
Output('download-button', 'disabled'),
|
111 |
+
Output('loading-output', 'children')],
|
112 |
Input('upscale-button', 'n_clicks'),
|
113 |
State('upload-image', 'contents'),
|
114 |
prevent_initial_call=True
|
115 |
)
|
116 |
def upscale_image_callback(n_clicks, contents):
|
117 |
if contents is None:
|
118 |
+
return None, True, ""
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
def upscale_thread():
|
121 |
+
upscale_image(contents)
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
threading.Thread(target=upscale_thread).start()
|
124 |
|
|
|
129 |
upscaled_image = html.Div([
|
130 |
html.Img(src=f"data:image/png;base64,{base64.b64encode(generated_file).decode()}", style={'width': '100%'})
|
131 |
])
|
132 |
+
return upscaled_image, False, ""
|
133 |
else:
|
134 |
+
return None, True, ""
|
135 |
|
136 |
@app.callback(
|
137 |
Output("download-image", "data"),
|