Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fooocus import FooocusProcessor # Adjust based on Fooocus setup
|
| 3 |
+
|
| 4 |
+
# Initialize Fooocus (update as needed for your model path or configs)
|
| 5 |
+
fooocus_processor = FooocusProcessor(model_path="path_to_model")
|
| 6 |
+
|
| 7 |
+
def process_with_fooocus(prompt, steps, guidance_scale):
|
| 8 |
+
"""
|
| 9 |
+
Generate an image using Fooocus based on user input.
|
| 10 |
+
"""
|
| 11 |
+
try:
|
| 12 |
+
result_image = fooocus_processor.generate(
|
| 13 |
+
prompt=prompt,
|
| 14 |
+
steps=steps,
|
| 15 |
+
guidance_scale=guidance_scale
|
| 16 |
+
)
|
| 17 |
+
return result_image
|
| 18 |
+
except Exception as e:
|
| 19 |
+
return f"An error occurred: {e}"
|
| 20 |
+
|
| 21 |
+
iface = gr.Interface(
|
| 22 |
+
fn=process_with_fooocus,
|
| 23 |
+
inputs=[
|
| 24 |
+
gr.Textbox(lines=2, placeholder="Enter your prompt here", label="Prompt"),
|
| 25 |
+
gr.Slider(1, 100, step=1, value=50, label="Steps"),
|
| 26 |
+
gr.Slider(1.0, 20.0, step=0.5, value=7.5, label="Guidance Scale"),
|
| 27 |
+
],
|
| 28 |
+
outputs=gr.Image(label="Generated Image"),
|
| 29 |
+
title="Fooocus Image Generator",
|
| 30 |
+
description="Generate high-quality images using Fooocus and Gradio."
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
iface.launch()
|