Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,17 @@
|
|
1 |
-
from optimum.intel import OVPipelineForText2Image
|
2 |
-
from openvino import Core, Model
|
3 |
import gradio as gr
|
4 |
|
5 |
# Load the model
|
6 |
model_id = "AIFunOver/FLUX.1-dev-openvino-fp16"
|
7 |
try:
|
8 |
-
model =
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
except Exception as e:
|
10 |
print(f"Error loading model: {e}")
|
11 |
exit(1)
|
@@ -16,10 +22,10 @@ def generate_image(prompt, num_inference_steps=50, guidance_scale=7.5):
|
|
16 |
# Generate image using the model
|
17 |
result = model(
|
18 |
prompt=prompt,
|
19 |
-
num_inference_steps=num_inference_steps,
|
20 |
-
guidance_scale=guidance_scale,
|
21 |
-
height=512,
|
22 |
-
width=512
|
23 |
)
|
24 |
image = result.images[0] # Extract the generated image
|
25 |
return image
|
@@ -41,4 +47,7 @@ interface = gr.Interface(
|
|
41 |
|
42 |
# Launch the Gradio app
|
43 |
if __name__ == "__main__":
|
44 |
-
|
|
|
|
|
|
|
|
1 |
+
from optimum.intel import OVStableDiffusionPipeline # Changed from OVPipelineForText2Image
|
2 |
+
from openvino import Core, Model # Updated to use non-deprecated openvino module
|
3 |
import gradio as gr
|
4 |
|
5 |
# Load the model
|
6 |
model_id = "AIFunOver/FLUX.1-dev-openvino-fp16"
|
7 |
try:
|
8 |
+
model = OVStableDiffusionPipeline.from_pretrained(
|
9 |
+
model_id,
|
10 |
+
export=True, # Enable export to OpenVINO IR if needed
|
11 |
+
device="AUTO" # Use AUTO for flexible device selection
|
12 |
+
)
|
13 |
+
# Save the model after export to avoid re-conversion
|
14 |
+
model.save_pretrained("./flux1_dev_openvino_fp16")
|
15 |
except Exception as e:
|
16 |
print(f"Error loading model: {e}")
|
17 |
exit(1)
|
|
|
22 |
# Generate image using the model
|
23 |
result = model(
|
24 |
prompt=prompt,
|
25 |
+
num_inference_steps=int(num_inference_steps), # Ensure integer input
|
26 |
+
guidance_scale=float(guidance_scale), # Ensure float input
|
27 |
+
height=512,
|
28 |
+
width=512
|
29 |
)
|
30 |
image = result.images[0] # Extract the generated image
|
31 |
return image
|
|
|
47 |
|
48 |
# Launch the Gradio app
|
49 |
if __name__ == "__main__":
|
50 |
+
try:
|
51 |
+
interface.launch(server_name="0.0.0.0", server_port=7860) # Explicit server settings
|
52 |
+
except Exception as e:
|
53 |
+
print(f"Error launching Gradio interface: {e}")
|