Spaces:
Runtime error
Runtime error
go back to random file names
Browse files3 unmodified lines456778910111213141557 unmodified lines737475727677787980748182838458 unmodified lines1431441451391461471481493 unmodified linesimport zipfileimport requestsimport tempfileimport jsonfrom io import BytesIOimport randomimport string
#image generation stufffrom PIL import Image
# gradio / hf stuffimport gradio as gr57 unmodified linesdef zip_images(image_paths_and_labels): zip_file_path = tempfile.NamedTemporaryFile(delete=False, suffix='.zip').name with zipfile.ZipFile(zip_file_path, 'w') as zipf: for image_url, label in image_paths_and_labels: for image_url, _ in image_paths_and_labels: image_content = download_image(image_url) # Generate a random filename for the image random_filename = ''.join(random.choices(string.ascii_letters + string.digits, k=10)) + ".png" # Write the image content to the zip file with the random filename zipf.writestr(label + ".png", image_content) zipf.writestr(random_filename, image_content) return zip_file_path
58 unmodified lines text = gr.Textbox(label="What do you want to create?", placeholder="Enter your text and then click on the \"Image Generate\" button")
model = gr.Dropdown(choices=["dall-e-2", "dall-e-3"], label="Model", value="dall-e-3") model = gr.Dropdown(choices=["dall-e-2", "dall-e-3"], label="Model", value="dall-e-2") btn = gr.Button("Generate Images") output_images = gr.Gallery(label="Image Outputs", show_label=True, columns=[3], rows=[1], object_fit="contain", height="auto", allow_preview=False)app.py+11-4