Update app.py
Browse files
app.py
CHANGED
|
@@ -90,34 +90,26 @@ def transform_my_model(content_image, style_image):
|
|
| 90 |
logger.error(f"Error in transform_my_model: {str(e)}")
|
| 91 |
raise
|
| 92 |
|
| 93 |
-
#
|
| 94 |
-
|
| 95 |
-
["Content_Images/contnt12.jpg", "VG516.jpg"],
|
| 96 |
-
["Content_Images/contnt2.jpg", "Content_Images/styl9.jpg"],
|
| 97 |
-
["Content_Images/contnt.jpg", "Content_Images/styl22.jpg"]
|
| 98 |
-
]
|
| 99 |
-
|
| 100 |
-
valid_examples = []
|
| 101 |
-
for content_path, style_path in example_images:
|
| 102 |
-
if os.path.exists(content_path) and os.path.exists(style_path):
|
| 103 |
-
valid_examples.append([content_path, style_path])
|
| 104 |
-
else:
|
| 105 |
-
logger.warning(f"Example image not found: {content_path} or {style_path}")
|
| 106 |
|
|
|
|
| 107 |
demo = gr.Interface(
|
| 108 |
fn=transform_my_model,
|
| 109 |
-
inputs=[
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
title="Neural Style Transfer",
|
| 112 |
description="Upload a content image and a style image to create a stylized version of your content image.",
|
| 113 |
-
examples=
|
| 114 |
-
|
| 115 |
)
|
| 116 |
|
| 117 |
if __name__ == "__main__":
|
| 118 |
demo.launch(
|
| 119 |
server_name="0.0.0.0",
|
| 120 |
server_port=7860,
|
| 121 |
-
share=True
|
| 122 |
-
show_error=True
|
| 123 |
)
|
|
|
|
| 90 |
logger.error(f"Error in transform_my_model: {str(e)}")
|
| 91 |
raise
|
| 92 |
|
| 93 |
+
# Create examples directory if it doesn't exist
|
| 94 |
+
os.makedirs("examples", exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
# Create the Gradio interface with minimal configuration
|
| 97 |
demo = gr.Interface(
|
| 98 |
fn=transform_my_model,
|
| 99 |
+
inputs=[
|
| 100 |
+
gr.Image(type="numpy", label="Content Image"),
|
| 101 |
+
gr.Image(type="numpy", label="Style Image")
|
| 102 |
+
],
|
| 103 |
+
outputs=gr.Image(type="pil", label="Result"),
|
| 104 |
title="Neural Style Transfer",
|
| 105 |
description="Upload a content image and a style image to create a stylized version of your content image.",
|
| 106 |
+
examples=None, # Disable examples to avoid API issues
|
| 107 |
+
allow_flagging="never" # Disable flagging to avoid API issues
|
| 108 |
)
|
| 109 |
|
| 110 |
if __name__ == "__main__":
|
| 111 |
demo.launch(
|
| 112 |
server_name="0.0.0.0",
|
| 113 |
server_port=7860,
|
| 114 |
+
share=True
|
|
|
|
| 115 |
)
|