Spaces:
Sleeping
Sleeping
Muhammad Waqas
commited on
Commit
·
2bc3ef7
1
Parent(s):
739515b
Test Commit
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ from dotenv import load_dotenv
|
|
| 11 |
from flask import Flask, request, jsonify, render_template, send_file
|
| 12 |
from PIL import Image
|
| 13 |
|
| 14 |
-
# Load environment variables from the .env file
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
# Initialize Flask app
|
|
@@ -96,7 +96,7 @@ def generate_image():
|
|
| 96 |
token = request.headers.get('Authorization')
|
| 97 |
|
| 98 |
# token = "Bearer JDJiJDEyJDgwbUJwQTFrQ0JYdS9lR2R4ZEZWdmV3WS9VTmlCeHNtc2txbnBITjR4Qm96ZmFnVUkvNDlh"
|
| 99 |
-
|
| 100 |
if token is None:
|
| 101 |
return jsonify({'error': 'No token provided'}), 400
|
| 102 |
if token.startswith("Bearer "):
|
|
@@ -109,17 +109,17 @@ def generate_image():
|
|
| 109 |
return jsonify({'error': 'No text prompt provided'}), 400
|
| 110 |
|
| 111 |
text_prompt = data['text_prompt']
|
| 112 |
-
|
| 113 |
# Get the path to the current file's directory
|
| 114 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 115 |
file_path = os.path.join(current_dir, 'workflows/flux1_dev_checkpoint_workflow_api.json')
|
| 116 |
-
|
| 117 |
with open(file_path, 'r', encoding='utf-8') as file:
|
| 118 |
workflow_jsondata = file.read()
|
| 119 |
|
| 120 |
prompt = json.loads(workflow_jsondata)
|
| 121 |
prompt["6"]["inputs"]["text"] = text_prompt
|
| 122 |
-
|
| 123 |
# prompt["7"]["inputs"]["text"] = "text, watermark, low quality, extra hands, extra legs."
|
| 124 |
# seednum = random.randint(1, 9999999999999)
|
| 125 |
# prompt["3"]["inputs"]["seed"] = seednum
|
|
|
|
| 11 |
from flask import Flask, request, jsonify, render_template, send_file
|
| 12 |
from PIL import Image
|
| 13 |
|
| 14 |
+
# Load environment variables from the .env file.
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
# Initialize Flask app
|
|
|
|
| 96 |
token = request.headers.get('Authorization')
|
| 97 |
|
| 98 |
# token = "Bearer JDJiJDEyJDgwbUJwQTFrQ0JYdS9lR2R4ZEZWdmV3WS9VTmlCeHNtc2txbnBITjR4Qm96ZmFnVUkvNDlh"
|
| 99 |
+
|
| 100 |
if token is None:
|
| 101 |
return jsonify({'error': 'No token provided'}), 400
|
| 102 |
if token.startswith("Bearer "):
|
|
|
|
| 109 |
return jsonify({'error': 'No text prompt provided'}), 400
|
| 110 |
|
| 111 |
text_prompt = data['text_prompt']
|
| 112 |
+
|
| 113 |
# Get the path to the current file's directory
|
| 114 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 115 |
file_path = os.path.join(current_dir, 'workflows/flux1_dev_checkpoint_workflow_api.json')
|
| 116 |
+
|
| 117 |
with open(file_path, 'r', encoding='utf-8') as file:
|
| 118 |
workflow_jsondata = file.read()
|
| 119 |
|
| 120 |
prompt = json.loads(workflow_jsondata)
|
| 121 |
prompt["6"]["inputs"]["text"] = text_prompt
|
| 122 |
+
|
| 123 |
# prompt["7"]["inputs"]["text"] = "text, watermark, low quality, extra hands, extra legs."
|
| 124 |
# seednum = random.randint(1, 9999999999999)
|
| 125 |
# prompt["3"]["inputs"]["seed"] = seednum
|