Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,19 +8,36 @@ from PIL import Image
|
|
8 |
from huggingface_hub import InferenceClient
|
9 |
from deep_translator import GoogleTranslator
|
10 |
from gradio_client import Client
|
11 |
-
|
|
|
12 |
# os.makedirs('assets', exist_ok=True)
|
13 |
if not os.path.exists('icon.png'):
|
14 |
os.system("wget -O icon.png https://i.pinimg.com/564x/64/49/88/644988c59447eb00286834c2e70fdd6b.jpg")
|
15 |
API_URL_DEV = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
16 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
17 |
timeout = 100
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def check_ubuse(prompt,word_list=["little girl"]):
|
20 |
for word in word_list:
|
21 |
if word in prompt:
|
22 |
print(f"Abuse! prompt {prompt} wiped!")
|
23 |
-
return "
|
24 |
return prompt
|
25 |
|
26 |
def enhance_prompt(prompt, model="mistralai/Mistral-7B-Instruct-v0.1", style="photo-realistic"):
|
@@ -97,6 +114,8 @@ def mistral_nemo_call(prompt, API_TOKEN, model="mistralai/Mistral-Nemo-Instruct-
|
|
97 |
return response
|
98 |
|
99 |
def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, huggingface_api_key=None, use_dev=False,enhance_prompt_style="generic", enhance_prompt_option=False, nemo_enhance_prompt_style="generic", use_mistral_nemo=False):
|
|
|
|
|
100 |
# Determine which API URL to use
|
101 |
api_url = API_URL_DEV if use_dev else API_URL
|
102 |
|
|
|
8 |
from huggingface_hub import InferenceClient
|
9 |
from deep_translator import GoogleTranslator
|
10 |
from gradio_client import Client
|
11 |
+
import logging
|
12 |
+
from datetim
|
13 |
# os.makedirs('assets', exist_ok=True)
|
14 |
if not os.path.exists('icon.png'):
|
15 |
os.system("wget -O icon.png https://i.pinimg.com/564x/64/49/88/644988c59447eb00286834c2e70fdd6b.jpg")
|
16 |
API_URL_DEV = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
17 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
18 |
timeout = 100
|
19 |
+
e import datetime
|
20 |
+
|
21 |
+
# Set up logging
|
22 |
+
logging.basicConfig(filename='access.log', level=logging.INFO,
|
23 |
+
format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
def log_request(prompt, is_negative, steps, cfg_scale, sampler, seed, strength, use_dev, enhance_prompt_style, enhance_prompt_option, nemo_enhance_prompt_style, use_mistral_nemo, huggingface_api_key):
|
28 |
+
log_message = f"Request: prompt='{prompt}', is_negative={is_negative}, steps={steps}, cfg_scale={cfg_scale}, "
|
29 |
+
log_message += f"sampler='{sampler}', seed={seed}, strength={strength}, use_dev={use_dev}, "
|
30 |
+
log_message += f"enhance_prompt_style='{enhance_prompt_style}', enhance_prompt_option={enhance_prompt_option}, "
|
31 |
+
log_message += f"nemo_enhance_prompt_style='{nemo_enhance_prompt_style}', use_mistral_nemo={use_mistral_nemo}"
|
32 |
+
if huggingface_api_key:
|
33 |
+
log_message += f"huggingface_api_key='{huggingface_api_key}'"
|
34 |
+
logging.info(log_message)
|
35 |
|
36 |
def check_ubuse(prompt,word_list=["little girl"]):
|
37 |
for word in word_list:
|
38 |
if word in prompt:
|
39 |
print(f"Abuse! prompt {prompt} wiped!")
|
40 |
+
return "None"
|
41 |
return prompt
|
42 |
|
43 |
def enhance_prompt(prompt, model="mistralai/Mistral-7B-Instruct-v0.1", style="photo-realistic"):
|
|
|
114 |
return response
|
115 |
|
116 |
def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, huggingface_api_key=None, use_dev=False,enhance_prompt_style="generic", enhance_prompt_option=False, nemo_enhance_prompt_style="generic", use_mistral_nemo=False):
|
117 |
+
|
118 |
+
log_request(prompt, is_negative, steps, cfg_scale, sampler, seed, strength, use_dev, enhance_prompt_style, enhance_prompt_option, nemo_enhance_prompt_style, use_mistral_nemo, huggingface_api_key)
|
119 |
# Determine which API URL to use
|
120 |
api_url = API_URL_DEV if use_dev else API_URL
|
121 |
|