Spaces:
Runtime error
Runtime error
test
Browse files
app.py
CHANGED
@@ -13,29 +13,6 @@ from datetime import datetime
|
|
13 |
from diffusers.models import AutoencoderKL
|
14 |
from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
|
15 |
|
16 |
-
js_code = """
|
17 |
-
function handle_image_click(idx) {
|
18 |
-
const images = document.querySelectorAll('#history_list img');
|
19 |
-
images.forEach(img => img.style.border = 'none');
|
20 |
-
images[idx].style.border = '2px solid blue';
|
21 |
-
gradioApp().querySelector('#selected_image img').src = images[idx].src;
|
22 |
-
gradioApp().querySelector('#selected_metadata textarea').value = JSON.stringify(generation_history[idx].metadata, null, 2);
|
23 |
-
}
|
24 |
-
|
25 |
-
document.addEventListener('DOMContentLoaded', (event) => {
|
26 |
-
const historyList = document.querySelector('#history_list');
|
27 |
-
if (historyList) {
|
28 |
-
historyList.addEventListener('click', (event) => {
|
29 |
-
if (event.target.tagName === 'IMG') {
|
30 |
-
const idx = Array.from(historyList.querySelectorAll('img')).indexOf(event.target);
|
31 |
-
handle_image_click(idx);
|
32 |
-
}
|
33 |
-
});
|
34 |
-
}
|
35 |
-
});
|
36 |
-
"""
|
37 |
-
|
38 |
-
|
39 |
logging.basicConfig(level=logging.INFO)
|
40 |
logger = logging.getLogger(__name__)
|
41 |
|
@@ -263,7 +240,7 @@ if torch.cuda.is_available():
|
|
263 |
else:
|
264 |
pipe = None
|
265 |
|
266 |
-
with gr.Blocks(css="style.css"
|
267 |
title = gr.HTML(
|
268 |
f"""<h1><span>{DESCRIPTION}</span></h1>""",
|
269 |
elem_id="title",
|
@@ -378,10 +355,10 @@ with gr.Blocks(css="style.css", js=js_code) as demo:
|
|
378 |
|
379 |
# Add history accordion
|
380 |
with gr.Accordion("Generation History", visible=False) as history_accordion:
|
381 |
-
history_list = gr.HTML(
|
382 |
with gr.Row():
|
383 |
-
selected_image = gr.Image(label="Selected Image", interactive=False
|
384 |
-
selected_metadata = gr.JSON(label="Selected Metadata", show_label=False
|
385 |
|
386 |
gr.Examples(
|
387 |
examples=config.examples,
|
@@ -480,4 +457,4 @@ with gr.Blocks(css="style.css", js=js_code) as demo:
|
|
480 |
# Add JavaScript for handling image clicks
|
481 |
|
482 |
|
483 |
-
demo.queue(max_size=20).launch(debug=IS_COLAB, share=IS_COLAB)
|
|
|
13 |
from diffusers.models import AutoencoderKL
|
14 |
from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
logging.basicConfig(level=logging.INFO)
|
17 |
logger = logging.getLogger(__name__)
|
18 |
|
|
|
240 |
else:
|
241 |
pipe = None
|
242 |
|
243 |
+
with gr.Blocks(css="style.css") as demo:
|
244 |
title = gr.HTML(
|
245 |
f"""<h1><span>{DESCRIPTION}</span></h1>""",
|
246 |
elem_id="title",
|
|
|
355 |
|
356 |
# Add history accordion
|
357 |
with gr.Accordion("Generation History", visible=False) as history_accordion:
|
358 |
+
history_list = gr.HTML()
|
359 |
with gr.Row():
|
360 |
+
selected_image = gr.Image(label="Selected Image", interactive=False)
|
361 |
+
selected_metadata = gr.JSON(label="Selected Metadata", show_label=False)
|
362 |
|
363 |
gr.Examples(
|
364 |
examples=config.examples,
|
|
|
457 |
# Add JavaScript for handling image clicks
|
458 |
|
459 |
|
460 |
+
demo.queue(max_size=20).launch(debug=IS_COLAB, share=IS_COLAB)
|