Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,8 @@ from diffusers import DiffusionPipeline
|
|
| 16 |
# CONFIG
|
| 17 |
# =====================================================
|
| 18 |
|
| 19 |
-
APP_USERNAME = os.getenv("APP_USERNAME"
|
| 20 |
-
APP_PASSWORD = os.getenv("APP_PASSWORD"
|
| 21 |
|
| 22 |
USER_LIST = [
|
| 23 |
x.strip()
|
|
@@ -199,6 +199,8 @@ def preview_prompt(prompt):
|
|
| 199 |
|
| 200 |
@spaces.GPU
|
| 201 |
def generate_text_to_image(prompt, use_groq, username):
|
|
|
|
|
|
|
| 202 |
fp = enhance_prompt(prompt) if use_groq else prompt
|
| 203 |
image = txt2img_pipe(prompt=fp, num_inference_steps=4, guidance_scale=0.0).images[0]
|
| 204 |
save_to_history(image, username)
|
|
@@ -210,6 +212,8 @@ def generate_text_to_image(prompt, use_groq, username):
|
|
| 210 |
|
| 211 |
@spaces.GPU
|
| 212 |
def edit_image(image_main, image_ref, prompt, use_groq, username):
|
|
|
|
|
|
|
| 213 |
if image_main is None:
|
| 214 |
raise gr.Error('Gambar utama wajib diupload')
|
| 215 |
fp = enhance_prompt(prompt) if use_groq else prompt
|
|
|
|
| 16 |
# CONFIG
|
| 17 |
# =====================================================
|
| 18 |
|
| 19 |
+
APP_USERNAME = os.getenv("APP_USERNAME")
|
| 20 |
+
APP_PASSWORD = os.getenv("APP_PASSWORD")
|
| 21 |
|
| 22 |
USER_LIST = [
|
| 23 |
x.strip()
|
|
|
|
| 199 |
|
| 200 |
@spaces.GPU
|
| 201 |
def generate_text_to_image(prompt, use_groq, username):
|
| 202 |
+
# Clear cache right before generation to give FLUX breathing room
|
| 203 |
+
torch.cuda.empty_cache()
|
| 204 |
fp = enhance_prompt(prompt) if use_groq else prompt
|
| 205 |
image = txt2img_pipe(prompt=fp, num_inference_steps=4, guidance_scale=0.0).images[0]
|
| 206 |
save_to_history(image, username)
|
|
|
|
| 212 |
|
| 213 |
@spaces.GPU
|
| 214 |
def edit_image(image_main, image_ref, prompt, use_groq, username):
|
| 215 |
+
# Clear cache right before generation to give FLUX breathing room
|
| 216 |
+
torch.cuda.empty_cache()
|
| 217 |
if image_main is None:
|
| 218 |
raise gr.Error('Gambar utama wajib diupload')
|
| 219 |
fp = enhance_prompt(prompt) if use_groq else prompt
|