Commit
·
806b780
1
Parent(s):
88632af
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,8 @@
|
|
| 1 |
-
# !pip install gradio
|
| 2 |
-
# !pip install openai
|
| 3 |
-
|
| 4 |
-
# import gradio as gr
|
| 5 |
-
# import openai
|
| 6 |
-
# import base64
|
| 7 |
-
# from PIL import Image
|
| 8 |
-
# from IPython.display import display, Image
|
| 9 |
-
# from PIL import Image as PILImage
|
| 10 |
-
# from io import BytesIO
|
| 11 |
-
# import numpy as np
|
| 12 |
-
# import io
|
| 13 |
-
# import cv2
|
| 14 |
-
|
| 15 |
import gradio as gr
|
| 16 |
import openai
|
| 17 |
import os
|
| 18 |
|
| 19 |
-
|
| 20 |
-
openai.api_key = "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"
|
| 21 |
-
|
| 22 |
-
# openai.api_key = os.environ.get("OPENAI_API_KEY")
|
| 23 |
|
| 24 |
# Dalle API
|
| 25 |
def open_ai_txt2img(prompt):
|
|
@@ -43,42 +26,4 @@ with gr.Blocks() as demo:
|
|
| 43 |
|
| 44 |
submit.click(generator, inputs=[prompt], outputs=[image1, image2, image3], api_name="mmd")
|
| 45 |
|
| 46 |
-
demo.launch()
|
| 47 |
-
|
| 48 |
-
# def image_variation(input):
|
| 49 |
-
# # Resize input image to 1024x1024
|
| 50 |
-
# input = cv2.resize(input, (1024, 1024))
|
| 51 |
-
|
| 52 |
-
# # Convert input to PIL Image
|
| 53 |
-
# input = np.uint8(input * 255)
|
| 54 |
-
# pil_image = PILImage.fromarray(input)
|
| 55 |
-
|
| 56 |
-
# # Convert PIL Image to byte stream
|
| 57 |
-
# byte_stream = io.BytesIO()
|
| 58 |
-
# pil_image.save(byte_stream, format='PNG')
|
| 59 |
-
# byte_array = byte_stream.getvalue()
|
| 60 |
-
|
| 61 |
-
# # Call OpenAI API to create variation
|
| 62 |
-
# response = openai.Image.create_variation(image=byte_array, n=6, size="1024x1024")
|
| 63 |
-
|
| 64 |
-
# # Return URL of first variation
|
| 65 |
-
# urls = [variation['url'] for variation in response['data']]
|
| 66 |
-
# return urls
|
| 67 |
-
|
| 68 |
-
# with gr.Blocks() as demo:
|
| 69 |
-
# with gr.Tab("Upload"):
|
| 70 |
-
# with gr.Row():
|
| 71 |
-
# image_input = gr.Image()
|
| 72 |
-
# with gr.Row():
|
| 73 |
-
# image_submit = gr.Button("Image Variation")
|
| 74 |
-
# with gr.Row():
|
| 75 |
-
# image_output = gr.Image()
|
| 76 |
-
# image_output2 = gr.Image()
|
| 77 |
-
# image_output3 = gr.Image()
|
| 78 |
-
# with gr.Row():
|
| 79 |
-
# image_output4 = gr.Image()
|
| 80 |
-
# image_output5 = gr.Image()
|
| 81 |
-
# image_output6 = gr.Image()
|
| 82 |
-
# image_submit.click(image_variation, inputs=[image_input], outputs=[image_output, image_output2, image_output3, image_output4, image_output5, image_output6])
|
| 83 |
-
|
| 84 |
-
# demo.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Dalle API
|
| 8 |
def open_ai_txt2img(prompt):
|
|
|
|
| 26 |
|
| 27 |
submit.click(generator, inputs=[prompt], outputs=[image1, image2, image3], api_name="mmd")
|
| 28 |
|
| 29 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|