Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
|
|
|
| 4 |
from datetime import datetime
|
|
|
|
| 5 |
import random
|
| 6 |
|
| 7 |
#----------Start of theme----------
|
|
@@ -38,6 +40,12 @@ theme = gr.themes.Soft(
|
|
| 38 |
)
|
| 39 |
#----------End of theme----------
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
def flip_image(x):
|
| 42 |
return np.fliplr(x)
|
| 43 |
|
|
@@ -284,8 +292,31 @@ css = """
|
|
| 284 |
with gr.Blocks(theme=theme, css=css) as app:
|
| 285 |
gr.HTML("<center><h6>🎨 Image Studio</h6></center>")
|
| 286 |
with gr.Tab("Text to Image"):
|
| 287 |
-
|
| 288 |
-
gr.load("models/XLabs-AI/flux-RealismLora")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
with gr.Tab("Flip Image"):
|
| 291 |
with gr.Row():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
| 4 |
+
import os
|
| 5 |
from datetime import datetime
|
| 6 |
+
from huggingface_hub import HfInferenceEndpoint
|
| 7 |
import random
|
| 8 |
|
| 9 |
#----------Start of theme----------
|
|
|
|
| 40 |
)
|
| 41 |
#----------End of theme----------
|
| 42 |
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
| 46 |
+
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
| 47 |
+
timeout = 100
|
| 48 |
+
|
| 49 |
def flip_image(x):
|
| 50 |
return np.fliplr(x)
|
| 51 |
|
|
|
|
| 292 |
with gr.Blocks(theme=theme, css=css) as app:
|
| 293 |
gr.HTML("<center><h6>🎨 Image Studio</h6></center>")
|
| 294 |
with gr.Tab("Text to Image"):
|
| 295 |
+
#gr.load("models/digiplay/AnalogMadness-realistic-model-v7")
|
| 296 |
+
#gr.load("models/XLabs-AI/flux-RealismLora")
|
| 297 |
+
endpoint = HfInferenceEndpoint(
|
| 298 |
+
repo_id="XLabs-AI/flux-RealismLora",
|
| 299 |
+
task="text-to-image",
|
| 300 |
+
#token=API_KEY
|
| 301 |
+
)
|
| 302 |
+
|
| 303 |
+
def generate_image(text):
|
| 304 |
+
response = endpoint.text_to_image(
|
| 305 |
+
text,
|
| 306 |
+
guidance_scale=5, # Adjust as needed
|
| 307 |
+
steps=50, # Adjust as needed
|
| 308 |
+
height=1152, # Adjust as needed
|
| 309 |
+
width=896 # Adjust as needed
|
| 310 |
+
)
|
| 311 |
+
return response
|
| 312 |
+
|
| 313 |
+
iface = gr.Interface(
|
| 314 |
+
fn=generate_image,
|
| 315 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
|
| 316 |
+
outputs=gr.Image(),
|
| 317 |
+
title="Flux Text-to-Image",
|
| 318 |
+
description="Generate images using the XLabs-AI/flux-RealismLora model.",
|
| 319 |
+
)
|
| 320 |
|
| 321 |
with gr.Tab("Flip Image"):
|
| 322 |
with gr.Row():
|