Leeps commited on
Commit
266a587
1 Parent(s): fc8357c

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. .DS_Store +0 -0
  2. api/index.py +13 -40
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
api/index.py CHANGED
@@ -64,16 +64,20 @@ def image_classifier(moodboard, prompt):
64
 
65
  # Call Stable Diffusion API with the response from OpenAI
66
  input = {
 
 
67
  "prompt": "high quality render of " + prompt + ", " + openai_response[20:],
68
- "output_format": "jpg"
 
 
 
 
69
  }
70
 
71
  output = replicate.run(
72
- "stability-ai/stable-diffusion-3",
73
  input=input
74
  )
75
-
76
- print(output)
77
 
78
  # Download the image from the URL
79
  image_url = output[0]
@@ -82,50 +86,19 @@ def image_classifier(moodboard, prompt):
82
  print(response)
83
  img1 = Image.open(io.BytesIO(response.content))
84
 
85
- input = {
86
- "prompt": "high quality render of " + prompt + ", " + openai_response[20:],
87
- "aspect_ratio": "3:2",
88
- "output_format": "jpg",
89
- "cfg":6
90
- }
91
-
92
- output = replicate.run(
93
- "stability-ai/stable-diffusion-3",
94
- input=input
95
- )
96
-
97
- print(output)
98
-
99
- # Download the image from the URL
100
- image_url = output[0]
101
  print(image_url)
102
  response = requests.get(image_url)
103
  print(response)
104
  img2 = Image.open(io.BytesIO(response.content))
105
 
106
- input = {
107
- "prompt": "high quality render of " + prompt + ", " + openai_response[20:],
108
- "aspect_ratio": "4:5",
109
- "output_format": "jpg",
110
- "cfg":5.5,
111
- "output_quality": 85
112
- }
113
-
114
- output = replicate.run(
115
- "stability-ai/stable-diffusion-3",
116
- input=input
117
- )
118
-
119
- print(output)
120
-
121
- # Download the image from the URL
122
- image_url = output[0]
123
  print(image_url)
124
  response = requests.get(image_url)
125
  print(response)
126
  img3 = Image.open(io.BytesIO(response.content))
127
-
128
- return [img1, img2, img3]
129
 
130
 
131
  # app = Flask(__name__)
@@ -135,4 +108,4 @@ def image_classifier(moodboard, prompt):
135
  # def index():
136
 
137
  demo = gr.Interface(fn=image_classifier, inputs=["image", "text"], outputs=["image", "image", "image"])
138
- demo.launch()
 
64
 
65
  # Call Stable Diffusion API with the response from OpenAI
66
  input = {
67
+ "width": 768,
68
+ "height": 768,
69
  "prompt": "high quality render of " + prompt + ", " + openai_response[20:],
70
+ "negative_prompt": "worst quality, low quality, illustration, 2d, painting, cartoons, sketch",
71
+ "refine": "expert_ensemble_refiner",
72
+ "apply_watermark": False,
73
+ "num_inference_steps": 25,
74
+ "num_outputs": 3
75
  }
76
 
77
  output = replicate.run(
78
+ "stability-ai/sdxl:7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc",
79
  input=input
80
  )
 
 
81
 
82
  # Download the image from the URL
83
  image_url = output[0]
 
86
  print(response)
87
  img1 = Image.open(io.BytesIO(response.content))
88
 
89
+ image_url = output[1]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  print(image_url)
91
  response = requests.get(image_url)
92
  print(response)
93
  img2 = Image.open(io.BytesIO(response.content))
94
 
95
+ image_url = output[2]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  print(image_url)
97
  response = requests.get(image_url)
98
  print(response)
99
  img3 = Image.open(io.BytesIO(response.content))
100
+
101
+ return [img1, img2, img3] # Return the image object
102
 
103
 
104
  # app = Flask(__name__)
 
108
  # def index():
109
 
110
  demo = gr.Interface(fn=image_classifier, inputs=["image", "text"], outputs=["image", "image", "image"])
111
+ demo.launch(share=True)