Spaces:
Runtime error
Runtime error
go back to random file names
Browse files3 unmodified lines456789101157 unmodified lines69707172737475767758 unmodified lines1361371381391401411423 unmodified linesimport zipfileimport requestsimport tempfileimport jsonfrom io import BytesIO# gradio / hf stuffimport gradio as gr57 unmodified linesdef zip_images(image_paths_and_labels):zip_file_path = tempfile.NamedTemporaryFile(delete=False, suffix='.zip').namewith zipfile.ZipFile(zip_file_path, 'w') as zipf:for image_url, label in image_paths_and_labels:image_content = download_image(image_url)zipf.writestr(label + ".png", image_content)return zip_file_path58 unmodified linestext = 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")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)3 unmodified lines45678910111213141557 unmodified lines73747576777879808182838458 unmodified lines1431441451461471481493 unmodified linesimport zipfileimport requestsimport tempfilefrom 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').namewith zipfile.ZipFile(zip_file_path, 'w') as zipf:for image_url, _ in image_paths_and_labels:image_content = download_image(image_url)# Generate a random filename for the imagerandom_filename = ''.join(random.choices(string.ascii_letters + string.digits, k=10)) + ".png"# Write the image content to the zip file with the random filenamezipf.writestr(random_filename, image_content)return zip_file_path58 unmodified linestext = 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-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