Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,13 +10,41 @@ from deep_translator import GoogleTranslator
|
|
10 |
from gradio_client import Client
|
11 |
import logging
|
12 |
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
20 |
|
21 |
# Set up logging
|
22 |
logging.basicConfig(filename='access.log', level=logging.INFO,
|
@@ -24,7 +52,7 @@ logging.basicConfig(filename='access.log', level=logging.INFO,
|
|
24 |
|
25 |
|
26 |
|
27 |
-
def
|
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}, "
|
|
|
10 |
from gradio_client import Client
|
11 |
import logging
|
12 |
from datetime import datetime
|
13 |
+
|
14 |
+
import sqlite3
|
15 |
+
from datetime import datetime
|
16 |
+
|
17 |
+
# Initialize the database
|
18 |
+
def init_db(file='logs.db'):
|
19 |
+
conn = sqlite3.connect(file)
|
20 |
+
c = conn.cursor()
|
21 |
+
c.execute('''CREATE TABLE IF NOT EXISTS logs
|
22 |
+
(timestamp TEXT, message TEXT)''')
|
23 |
+
conn.commit()
|
24 |
+
conn.close()
|
25 |
+
|
26 |
+
# Log a request
|
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 |
+
|
35 |
+
conn = sqlite3.connect('acces_log.log')
|
36 |
+
c = conn.cursor()
|
37 |
+
c.execute("INSERT INTO logs VALUES (?, ?)", (datetime.now().isoformat(), log_message))
|
38 |
+
conn.commit()
|
39 |
+
conn.close()
|
40 |
+
|
41 |
# os.makedirs('assets', exist_ok=True)
|
42 |
if not os.path.exists('icon.png'):
|
43 |
os.system("wget -O icon.png https://i.pinimg.com/564x/64/49/88/644988c59447eb00286834c2e70fdd6b.jpg")
|
44 |
API_URL_DEV = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
45 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
46 |
timeout = 100
|
47 |
+
init_db('acces_log.log')
|
48 |
|
49 |
# Set up logging
|
50 |
logging.basicConfig(filename='access.log', level=logging.INFO,
|
|
|
52 |
|
53 |
|
54 |
|
55 |
+
def log_requestold(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):
|
56 |
log_message = f"Request: prompt='{prompt}', is_negative={is_negative}, steps={steps}, cfg_scale={cfg_scale}, "
|
57 |
log_message += f"sampler='{sampler}', seed={seed}, strength={strength}, use_dev={use_dev}, "
|
58 |
log_message += f"enhance_prompt_style='{enhance_prompt_style}', enhance_prompt_option={enhance_prompt_option}, "
|