Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -408,7 +408,7 @@ def generate_high_quality_image(prompt, model_choice="dreamshaper-8", style="chi
|
|
| 408 |
"""Legacy function for backward compatibility"""
|
| 409 |
return generate_consistent_image(prompt, model_choice, style, [], {}, 1)
|
| 410 |
|
| 411 |
-
# LOCAL FILE MANAGEMENT FUNCTIONS
|
| 412 |
def save_image_to_local(image, prompt, style="test"):
|
| 413 |
"""Save image to local persistent storage"""
|
| 414 |
try:
|
|
@@ -488,7 +488,7 @@ def refresh_local_images():
|
|
| 488 |
print(f"Error refreshing local images: {e}")
|
| 489 |
return []
|
| 490 |
|
| 491 |
-
# OCI BUCKET FUNCTIONS
|
| 492 |
def save_to_oci_bucket(image, text_content, story_title, page_number, file_type="image"):
|
| 493 |
"""Save both images and text to OCI bucket via your OCI API"""
|
| 494 |
try:
|
|
@@ -887,6 +887,38 @@ async def delete_local_image_api(filename: str):
|
|
| 887 |
except Exception as e:
|
| 888 |
return {"status": "error", "message": str(e)}
|
| 889 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 890 |
# Enhanced Gradio interface with dynamic character testing
|
| 891 |
def create_gradio_interface():
|
| 892 |
"""Create Gradio interface with dynamic character consistency features"""
|
|
|
|
| 408 |
"""Legacy function for backward compatibility"""
|
| 409 |
return generate_consistent_image(prompt, model_choice, style, [], {}, 1)
|
| 410 |
|
| 411 |
+
# LOCAL FILE MANAGEMENT FUNCTIONS
|
| 412 |
def save_image_to_local(image, prompt, style="test"):
|
| 413 |
"""Save image to local persistent storage"""
|
| 414 |
try:
|
|
|
|
| 488 |
print(f"Error refreshing local images: {e}")
|
| 489 |
return []
|
| 490 |
|
| 491 |
+
# OCI BUCKET FUNCTIONS
|
| 492 |
def save_to_oci_bucket(image, text_content, story_title, page_number, file_type="image"):
|
| 493 |
"""Save both images and text to OCI bucket via your OCI API"""
|
| 494 |
try:
|
|
|
|
| 887 |
except Exception as e:
|
| 888 |
return {"status": "error", "message": str(e)}
|
| 889 |
|
| 890 |
+
# MISSING HELPER FUNCTIONS FOR GRADIO INTERFACE
|
| 891 |
+
def delete_current_image(filepath):
|
| 892 |
+
"""Delete the currently displayed image"""
|
| 893 |
+
if not filepath:
|
| 894 |
+
return "❌ No image to delete", None, None, refresh_local_images()
|
| 895 |
+
|
| 896 |
+
success, message = delete_local_image(filepath)
|
| 897 |
+
updated_files = refresh_local_images()
|
| 898 |
+
|
| 899 |
+
if success:
|
| 900 |
+
status_msg = f"✅ {message}"
|
| 901 |
+
return status_msg, None, "Image deleted successfully!", updated_files
|
| 902 |
+
else:
|
| 903 |
+
return f"❌ {message}", None, "Delete failed", updated_files
|
| 904 |
+
|
| 905 |
+
def clear_all_images():
|
| 906 |
+
"""Delete all local images"""
|
| 907 |
+
try:
|
| 908 |
+
storage_info = get_local_storage_info()
|
| 909 |
+
deleted_count = 0
|
| 910 |
+
|
| 911 |
+
if "images" in storage_info:
|
| 912 |
+
for image_info in storage_info["images"]:
|
| 913 |
+
success, _ = delete_local_image(image_info["path"])
|
| 914 |
+
if success:
|
| 915 |
+
deleted_count += 1
|
| 916 |
+
|
| 917 |
+
updated_files = refresh_local_images()
|
| 918 |
+
return f"✅ Deleted {deleted_count} images", updated_files
|
| 919 |
+
except Exception as e:
|
| 920 |
+
return f"❌ Error: {str(e)}", refresh_local_images()
|
| 921 |
+
|
| 922 |
# Enhanced Gradio interface with dynamic character testing
|
| 923 |
def create_gradio_interface():
|
| 924 |
"""Create Gradio interface with dynamic character consistency features"""
|