Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ from all_models import models
|
|
6 |
from io import BytesIO
|
7 |
from PIL import Image
|
8 |
from fastapi import FastAPI, Request
|
9 |
-
from fastapi.staticfiles import StaticFiles
|
10 |
from deep_translator import GoogleTranslator
|
11 |
|
12 |
css_code = """
|
@@ -86,10 +85,8 @@ async def api_generate(request: Request):
|
|
86 |
"image_format": "jpeg"
|
87 |
}
|
88 |
|
89 |
-
#
|
90 |
-
|
91 |
-
gr.Markdown("# Image Generation Tool")
|
92 |
-
|
93 |
with gr.Row():
|
94 |
# Left Column (50% width)
|
95 |
with gr.Column(scale=1, min_width=400):
|
@@ -135,6 +132,7 @@ with gr.Blocks(css=css_code, title="Image Generation App") as demo:
|
|
135 |
container=False
|
136 |
)
|
137 |
|
|
|
138 |
def generate_wrapper(model_str, prompt):
|
139 |
# Translate prompt to English
|
140 |
translated_prompt = translator.translate(prompt)
|
@@ -180,11 +178,15 @@ with gr.Blocks(css=css_code, title="Image Generation App") as demo:
|
|
180 |
cancels=[gen_event]
|
181 |
)
|
182 |
|
|
|
|
|
|
|
|
|
|
|
183 |
# Enable queue before mounting
|
184 |
demo.queue()
|
185 |
|
186 |
# Mount Gradio app to FastAPI
|
187 |
-
app.mount("/static", StaticFiles(directory="static"), name="static")
|
188 |
app = gr.mount_gradio_app(app, demo, path="/")
|
189 |
|
190 |
if __name__ == "__main__":
|
|
|
6 |
from io import BytesIO
|
7 |
from PIL import Image
|
8 |
from fastapi import FastAPI, Request
|
|
|
9 |
from deep_translator import GoogleTranslator
|
10 |
|
11 |
css_code = """
|
|
|
85 |
"image_format": "jpeg"
|
86 |
}
|
87 |
|
88 |
+
# Gradio Interface
|
89 |
+
def make_me():
|
|
|
|
|
90 |
with gr.Row():
|
91 |
# Left Column (50% width)
|
92 |
with gr.Column(scale=1, min_width=400):
|
|
|
132 |
container=False
|
133 |
)
|
134 |
|
135 |
+
# Functionality remains the same
|
136 |
def generate_wrapper(model_str, prompt):
|
137 |
# Translate prompt to English
|
138 |
translated_prompt = translator.translate(prompt)
|
|
|
178 |
cancels=[gen_event]
|
179 |
)
|
180 |
|
181 |
+
# Create Gradio app
|
182 |
+
with gr.Blocks(css=css_code, title="Image Generation App") as demo:
|
183 |
+
gr.Markdown("# Image Generation Tool")
|
184 |
+
make_me()
|
185 |
+
|
186 |
# Enable queue before mounting
|
187 |
demo.queue()
|
188 |
|
189 |
# Mount Gradio app to FastAPI
|
|
|
190 |
app = gr.mount_gradio_app(app, demo, path="/")
|
191 |
|
192 |
if __name__ == "__main__":
|