creek

The AI Image Editor of 2030
commit 7a805962549c8e5379414999d2c524fddef49924
parent f5d99aeb344285afa0510e861ad089a2c4163f0b
Author: maydayv7 <maydayv7@gmail.com>
Date:   Thu,  4 Dec 2025 02:25:10 +0530

Switch to Nano Banana from Flux Schnell

Diffstat:
Mflask/README.md | 3+++
Mflask/index.py | 30++++++++++++------------------
Mflask/modal_app.py | 12++++++++----
3 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/flask/README.md b/flask/README.md @@ -1,5 +1,8 @@ # Backend +> [!NOTE] +> Python 3.11 is the preferred version for running the backend + This project provides a unified AI backend for image generation, inpainting, background removal, and captioning. It supports two modes of operation: ## 1. Local Server (`index.py`) diff --git a/flask/index.py b/flask/index.py @@ -554,39 +554,34 @@ def sketch_api(): return jsonify({"error": "Missing prompt"}), 400 # --- ENFORCE SHARPNESS IN PROMPT --- - # We append these words to ensure the "cartoon" style isn't blurry enhanced_prompt = f"{prompt}, sharp focus, high definition, 4k, vector art, crisp lines" if int(option) == 1: - # Flux Schnell (No change needed, it ignores guidance) - print(f"🚀 Using Flux Schnell for: {prompt}") - model_id = "fal-ai/flux/schnell" + # Nano Banana + print(f"🍌 Using Nano Banana for: {prompt}") + model_id = "fal-ai/nano-banana" arguments = { - "image_size": "square_hd", - "num_inference_steps": 4, - "enable_safety_checker": False, - "prompt": enhanced_prompt + "prompt": enhanced_prompt, + "num_images": 1, + "aspect_ratio": "1:1", + "output_format": "png" } elif int(option) == 2: - # Flux Dev (THIS IS THE FIX) + # Flux Dev print(f"🚀 Using Flux Dev for: {prompt}") model_id = "fal-ai/flux/dev" arguments = { "image_size": "square_hd", "num_inference_steps": 28, - - # 👇 KEY FIX: Set this to 3.5 or 4.0 for sharp images "guidance_scale": 3.5, - - # 👇 OPTIONAL: Makes it less likely to return black images "safety_tolerance": "2", - "enable_safety_checker": False, "prompt": enhanced_prompt } else: - return jsonify({"error": "Invalid option. Use 1 for Schnell, 2 for Dev."}), 400 + return jsonify({"error": "Invalid option. Use 1 for Nano Banana, 2 for Flux Dev."}), 400 + # Execute request handler = fal_client.submit( model_id, arguments=arguments @@ -597,7 +592,7 @@ def sketch_api(): if 'images' in result and len(result['images']) > 0: image_url = result['images'][0]['url'] print(f"✨ Success! Image generated: {image_url}") - + response = requests.get(image_url) if response.status_code == 200: img = Image.open(io.BytesIO(response.content)).convert("RGB") @@ -613,4 +608,4 @@ def sketch_api(): return jsonify({"status": "error", "message": str(e)}), 500 if __name__ == "__main__": - app.run(host='0.0.0.0', port=5000) -\ No newline at end of file + app.run(host='0.0.0.0', port=5000) diff --git a/flask/modal_app.py b/flask/modal_app.py @@ -377,14 +377,18 @@ class ModelBackend: ) if int(option) == 1: - model_id = "fal-ai/flux/schnell" + # Nano Banana + print(f"🍌 Using Nano Banana for: {prompt}") + model_id = "fal-ai/nano-banana" arguments = { - "image_size": "square_hd", - "num_inference_steps": 4, - "enable_safety_checker": False, "prompt": enhanced_prompt, + "num_images": 1, + "aspect_ratio": "1:1", + "output_format": "png" } else: + # Flux Dev + print(f"🚀 Using Flux Dev for: {prompt}") model_id = "fal-ai/flux/dev" arguments = { "image_size": "square_hd",