Spaces:
Sleeping
Sleeping
File size: 1,735 Bytes
2ec2ebd 773453a 2ec2ebd 680fd14 2ec2ebd 680fd14 6bd54bd 2ec2ebd 680fd14 2ec2ebd 1423ceb 2ec2ebd 6bd54bd 2ec2ebd 6bd54bd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import gradio as gr
import sys
# sys.path.append("LaVi-Bridge/test")
# from llama2_unet_diffusion_lens import call_diffusion_lens
from diffusion_lens import get_images
import gradio as gr
import os
import subprocess
def display_images(images):
# Prepare images for display
return [gr.Image(image) for image in images]
# def get_prompt(prompt):
# print('prompt:', prompt)
# print('calling diffusion lens')
# image = get_images(prompt, skip_layers=0)
# return image
#
# if __name__ == '__main__':
# with gr.Blocks() as demo:
# gallery = gr.Gallery(
# label="Generated images", show_label=False, elem_id="gallery",
# columns=[1], rows=[1], object_fit="contain", height="auto")
# btn = gr.Button("Generate images", scale=0)
#
# btn.click(get_prompt, 'text', gallery)
#
# demo.launch()
def get_prompt(prompt):
print('prompt:', prompt)
print('calling diffusion lens')
for skip_layers in range(24): # loop from 0 to 23
image = get_images(prompt, skip_layers=skip_layers)
gallery.update(image) # update the gallery with the new image
return "Images generated"
if __name__ == '__main__':
with gr.Blocks() as demo:
gallery = gr.Gallery(
label="Generated images", show_label=False, elem_id="gallery",
columns=[6], rows=[4], object_fit="contain", height="auto") # set rows to 24 to accommodate all images
btn = gr.Button("Generate images", scale=0)
text_input = gr.Interface(fn=get_prompt, inputs="text", outputs='Gallery', label='Intermediate images')
btn.click(get_prompt, text_input, gallery) # pass the text input interface to btn.click()
demo.launch() |