Spaces:
Sleeping
Sleeping
自良
commited on
Commit
·
e41dcba
1
Parent(s):
0b450c2
update requirements.txt
Browse files- logs/vote_log/2024-12-27-conv.json +3 -0
- logs/vote_log/gr_web_image_generation_multi.log +33 -0
- requirements.txt +12 -111
- serve/__pycache__/vote_utils.cpython-310.pyc +0 -0
- serve/vote_utils.py +0 -243
logs/vote_log/2024-12-27-conv.json
CHANGED
|
@@ -2,3 +2,6 @@
|
|
| 2 |
{"tstamp": 1735286365.2329, "type": "bothbad_vote", "models": ["GPT-4o + Stable Diffusion 3 Medium", "ChatDiT"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
| 3 |
{"tstamp": 1735286374.6751, "type": "leftvote", "models": ["GPT-4o + Emu2", "ChatDiT"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
| 4 |
{"tstamp": 1735286382.1211, "type": "leftvote", "models": ["GPT-4o + FLUX.1 [dev]", "GPT-4o + Emu2"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
{"tstamp": 1735286365.2329, "type": "bothbad_vote", "models": ["GPT-4o + Stable Diffusion 3 Medium", "ChatDiT"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
| 3 |
{"tstamp": 1735286374.6751, "type": "leftvote", "models": ["GPT-4o + Emu2", "ChatDiT"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
| 4 |
{"tstamp": 1735286382.1211, "type": "leftvote", "models": ["GPT-4o + FLUX.1 [dev]", "GPT-4o + Emu2"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
| 5 |
+
{"tstamp": 1735288723.7052, "type": "leftvote", "models": ["GPT-4o + PixArt-Sigma", "GPT-4o + OmniGen"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
| 6 |
+
{"tstamp": 1735288729.3576, "type": "leftvote", "models": ["GPT-4o + FLUX.1 [dev]", "GPT-4o + DALLE-3"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
| 7 |
+
{"tstamp": 1735288749.1708, "type": "leftvote", "models": ["GPT-4o + PixArt-Sigma", "GPT-4o + OmniGen"], "states": [{}, {}], "anony": true, "ip": "127.0.0.1"}
|
logs/vote_log/gr_web_image_generation_multi.log
CHANGED
|
@@ -497,3 +497,36 @@
|
|
| 497 |
2024-12-27 16:31:12 | ERROR | stderr | File "/opt/anaconda3/envs/tiger/lib/python3.10/threading.py", line 1116, in _wait_for_tstate_lock
|
| 498 |
2024-12-27 16:31:12 | ERROR | stderr | if lock.acquire(block, timeout):
|
| 499 |
2024-12-27 16:31:12 | ERROR | stderr | KeyboardInterrupt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
2024-12-27 16:31:12 | ERROR | stderr | File "/opt/anaconda3/envs/tiger/lib/python3.10/threading.py", line 1116, in _wait_for_tstate_lock
|
| 498 |
2024-12-27 16:31:12 | ERROR | stderr | if lock.acquire(block, timeout):
|
| 499 |
2024-12-27 16:31:12 | ERROR | stderr | KeyboardInterrupt
|
| 500 |
+
2024-12-27 16:38:03 | ERROR | stderr | Traceback (most recent call last):
|
| 501 |
+
2024-12-27 16:38:03 | ERROR | stderr | File "/Users/jasi/Documents/ali-vilab/huggingface/IDEA-Bench-Arena/app.py", line 63, in <module>
|
| 502 |
+
2024-12-27 16:38:03 | ERROR | stderr | demo = build_combine_demo(models, elo_results_file, leaderboard_table_file)
|
| 503 |
+
2024-12-27 16:38:03 | ERROR | stderr | File "/Users/jasi/Documents/ali-vilab/huggingface/IDEA-Bench-Arena/app.py", line 31, in build_combine_demo
|
| 504 |
+
2024-12-27 16:38:03 | ERROR | stderr | build_leaderboard_tab(elo_results_file['t2i_generation'], leaderboard_table_file['t2i_generation'])
|
| 505 |
+
2024-12-27 16:38:03 | ERROR | stderr | File "/Users/jasi/Documents/ali-vilab/huggingface/IDEA-Bench-Arena/serve/leaderboard.py", line 176, in build_leaderboard_tab
|
| 506 |
+
2024-12-27 16:38:03 | ERROR | stderr | elo_results = pickle.load(fin)
|
| 507 |
+
2024-12-27 16:38:03 | ERROR | stderr | ModuleNotFoundError: No module named 'plotly'
|
| 508 |
+
2024-12-27 16:38:06 | ERROR | stderr | Exception ignored in: <module 'threading' from '/opt/anaconda3/envs/arena/lib/python3.10/threading.py'>
|
| 509 |
+
2024-12-27 16:38:06 | ERROR | stderr | Traceback (most recent call last):
|
| 510 |
+
2024-12-27 16:38:06 | ERROR | stderr | File "/opt/anaconda3/envs/arena/lib/python3.10/threading.py", line 1567, in _shutdown
|
| 511 |
+
2024-12-27 16:38:06 | ERROR | stderr | lock.acquire()
|
| 512 |
+
2024-12-27 16:38:06 | ERROR | stderr | KeyboardInterrupt:
|
| 513 |
+
2024-12-27 16:38:25 | INFO | stdout | * Running on local URL: http://127.0.0.1:7860
|
| 514 |
+
2024-12-27 16:38:25 | INFO | stdout |
|
| 515 |
+
2024-12-27 16:38:25 | INFO | stdout | To create a public link, set `share=True` in `launch()`.
|
| 516 |
+
2024-12-27 16:38:43 | INFO | gradio_web_server_image_generation_multi | leftvote (named). ip: 127.0.0.1
|
| 517 |
+
2024-12-27 16:38:49 | INFO | gradio_web_server_image_generation_multi | leftvote (named). ip: 127.0.0.1
|
| 518 |
+
2024-12-27 16:39:09 | INFO | gradio_web_server_image_generation_multi | leftvote (named). ip: 127.0.0.1
|
| 519 |
+
2024-12-27 16:39:24 | INFO | stdout | Keyboard interruption in main thread... closing server.
|
| 520 |
+
2024-12-27 16:39:25 | INFO | stdout | Rerunning server... use `close()` to stop if you need to change `launch()` parameters.
|
| 521 |
+
2024-12-27 16:39:25 | INFO | stdout | ----
|
| 522 |
+
2024-12-27 16:39:25 | ERROR | stderr | Traceback (most recent call last):
|
| 523 |
+
2024-12-27 16:39:25 | ERROR | stderr | File "/Users/jasi/Documents/ali-vilab/huggingface/IDEA-Bench-Arena/app.py", line 65, in <module>
|
| 524 |
+
2024-12-27 16:39:25 | ERROR | stderr | demo.launch(server_port=server_port, root_path=ROOT_PATH, show_error=True)
|
| 525 |
+
2024-12-27 16:39:25 | ERROR | stderr | File "/opt/anaconda3/envs/arena/lib/python3.10/site-packages/gradio/blocks.py", line 2619, in launch
|
| 526 |
+
2024-12-27 16:39:25 | ERROR | stderr | raise ValueError(
|
| 527 |
+
2024-12-27 16:39:25 | ERROR | stderr | ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.
|
| 528 |
+
2024-12-27 16:39:25 | ERROR | stderr | Exception ignored in: <module 'threading' from '/opt/anaconda3/envs/arena/lib/python3.10/threading.py'>
|
| 529 |
+
2024-12-27 16:39:25 | ERROR | stderr | Traceback (most recent call last):
|
| 530 |
+
2024-12-27 16:39:25 | ERROR | stderr | File "/opt/anaconda3/envs/arena/lib/python3.10/threading.py", line 1567, in _shutdown
|
| 531 |
+
2024-12-27 16:39:25 | ERROR | stderr | lock.acquire()
|
| 532 |
+
2024-12-27 16:39:25 | ERROR | stderr | KeyboardInterrupt:
|
requirements.txt
CHANGED
|
@@ -1,154 +1,55 @@
|
|
| 1 |
-
accelerate==1.2.1
|
| 2 |
aiofiles==23.2.1
|
| 3 |
-
aiohappyeyeballs==2.4.4
|
| 4 |
-
aiohttp==3.11.11
|
| 5 |
-
aiosignal==1.3.2
|
| 6 |
-
altair==5.5.0
|
| 7 |
-
aniso8601==9.0.1
|
| 8 |
annotated-types==0.7.0
|
| 9 |
-
antlr4-python3-runtime==4.9.3
|
| 10 |
anyio==4.7.0
|
| 11 |
-
anykeystore==0.2
|
| 12 |
-
async-timeout==5.0.1
|
| 13 |
-
attrs==24.3.0
|
| 14 |
-
blinker==1.9.0
|
| 15 |
certifi==2024.12.14
|
| 16 |
-
charset-normalizer==3.4.
|
| 17 |
-
click==8.1.
|
| 18 |
-
contourpy==1.3.1
|
| 19 |
-
cryptacular==1.6.2
|
| 20 |
-
cycler==0.12.1
|
| 21 |
-
datasets==3.2.0
|
| 22 |
-
defusedxml==0.7.1
|
| 23 |
-
diffusers==0.31.0
|
| 24 |
-
dill==0.3.8
|
| 25 |
-
distro==1.9.0
|
| 26 |
-
einops==0.8.0
|
| 27 |
-
et_xmlfile==2.0.0
|
| 28 |
exceptiongroup==1.2.2
|
| 29 |
-
faiss-cpu==1.9.0.post1
|
| 30 |
-
fal_client==0.5.6
|
| 31 |
fastapi==0.115.6
|
| 32 |
-
ffmpy==0.
|
| 33 |
filelock==3.16.1
|
| 34 |
-
|
| 35 |
-
Flask==3.1.0
|
| 36 |
-
Flask-Cors==5.0.0
|
| 37 |
-
Flask-RESTful==0.3.10
|
| 38 |
-
fonttools==4.55.3
|
| 39 |
-
frozenlist==1.5.0
|
| 40 |
-
fsspec==2024.9.0
|
| 41 |
gradio==5.9.1
|
| 42 |
gradio_client==1.5.2
|
| 43 |
h11==0.14.0
|
| 44 |
-
h5py==3.12.1
|
| 45 |
httpcore==1.0.7
|
| 46 |
httpx==0.28.1
|
| 47 |
-
httpx-sse==0.4.0
|
| 48 |
huggingface-hub==0.27.0
|
| 49 |
-
hupper==1.12.1
|
| 50 |
idna==3.10
|
| 51 |
-
|
| 52 |
-
importlib_metadata==8.5.0
|
| 53 |
-
importlib_resources==6.4.5
|
| 54 |
-
itsdangerous==2.2.0
|
| 55 |
-
Jinja2==3.1.4
|
| 56 |
-
jiter==0.8.2
|
| 57 |
-
joblib==1.4.2
|
| 58 |
-
jsonschema==4.23.0
|
| 59 |
-
jsonschema-specifications==2024.10.1
|
| 60 |
-
kaleido==0.2.1
|
| 61 |
-
kiwisolver==1.4.7
|
| 62 |
-
lightning-utilities==0.11.9
|
| 63 |
markdown-it-py==3.0.0
|
| 64 |
MarkupSafe==2.1.5
|
| 65 |
-
matplotlib==3.10.0
|
| 66 |
mdurl==0.1.2
|
| 67 |
-
|
| 68 |
-
mpmath==1.3.0
|
| 69 |
-
multidict==6.1.0
|
| 70 |
-
multiprocess==0.70.16
|
| 71 |
-
narwhals==1.19.0
|
| 72 |
-
networkx==3.4.2
|
| 73 |
-
numpy==1.26.4
|
| 74 |
-
oauthlib==3.2.2
|
| 75 |
-
omegaconf==2.3.0
|
| 76 |
-
openai==1.58.1
|
| 77 |
-
opencv-python==4.10.0.84
|
| 78 |
-
openpyxl==3.1.5
|
| 79 |
orjson==3.10.12
|
| 80 |
packaging==24.2
|
| 81 |
pandas==2.2.3
|
| 82 |
-
|
| 83 |
-
pbkdf2==1.3
|
| 84 |
-
peft==0.14.0
|
| 85 |
-
pillow==10.4.0
|
| 86 |
-
plaster==1.1.2
|
| 87 |
-
plaster-pastedeploy==1.0.1
|
| 88 |
plotly==5.24.1
|
| 89 |
-
prometheus_client==0.21.1
|
| 90 |
-
propcache==0.2.1
|
| 91 |
-
psutil==6.1.1
|
| 92 |
-
pyarrow==18.1.0
|
| 93 |
pydantic==2.10.4
|
| 94 |
pydantic_core==2.27.2
|
| 95 |
pydub==0.25.1
|
| 96 |
Pygments==2.18.0
|
| 97 |
-
pyparsing==3.2.0
|
| 98 |
-
pyramid==2.0.2
|
| 99 |
-
pyramid-mailer==0.15.1
|
| 100 |
python-dateutil==2.9.0.post0
|
| 101 |
python-multipart==0.0.20
|
| 102 |
-
python3-openid==3.2.0
|
| 103 |
-
pytorch-lightning==2.4.0
|
| 104 |
pytz==2024.2
|
| 105 |
PyYAML==6.0.2
|
| 106 |
-
referencing==0.35.1
|
| 107 |
regex==2024.11.6
|
| 108 |
-
repoze.sendmail==4.4.1
|
| 109 |
requests==2.32.3
|
| 110 |
-
requests-oauthlib==2.0.0
|
| 111 |
rich==13.9.4
|
| 112 |
-
|
| 113 |
-
ruff==0.8.3
|
| 114 |
safehttpx==0.1.6
|
| 115 |
-
safetensors==0.4.5
|
| 116 |
-
scikit-learn==1.6.0
|
| 117 |
-
scipy==1.14.1
|
| 118 |
semantic-version==2.10.0
|
| 119 |
shellingham==1.5.4
|
| 120 |
six==1.17.0
|
| 121 |
sniffio==1.3.1
|
| 122 |
-
|
| 123 |
-
starlette==0.42.0
|
| 124 |
-
sympy==1.13.1
|
| 125 |
tenacity==9.0.0
|
| 126 |
-
|
| 127 |
-
threadpoolctl==3.5.0
|
| 128 |
-
tokenizers==0.21.0
|
| 129 |
-
tomlkit==0.12.0
|
| 130 |
-
torch==2.5.1
|
| 131 |
-
torchmetrics==1.6.0
|
| 132 |
-
torchvision==0.20.1
|
| 133 |
tqdm==4.67.1
|
| 134 |
-
transaction==5.0
|
| 135 |
-
transformers==4.47.1
|
| 136 |
-
translationstring==1.4
|
| 137 |
typer==0.15.1
|
| 138 |
typing_extensions==4.12.2
|
| 139 |
tzdata==2024.2
|
| 140 |
-
urllib3==2.
|
| 141 |
uvicorn==0.34.0
|
| 142 |
-
|
| 143 |
-
venusian==3.1.1
|
| 144 |
-
WebOb==1.8.9
|
| 145 |
-
websockets==11.0.3
|
| 146 |
-
Werkzeug==3.1.3
|
| 147 |
-
WTForms==3.2.1
|
| 148 |
-
wtforms-recaptcha==0.3.2
|
| 149 |
-
xxhash==3.5.0
|
| 150 |
-
yarl==1.18.3
|
| 151 |
-
zipp==3.21.0
|
| 152 |
-
zope.deprecation==5.0
|
| 153 |
-
zope.interface==7.2
|
| 154 |
-
zope.sqlalchemy==3.1
|
|
|
|
|
|
|
| 1 |
aiofiles==23.2.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
annotated-types==0.7.0
|
|
|
|
| 3 |
anyio==4.7.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
certifi==2024.12.14
|
| 5 |
+
charset-normalizer==3.4.1
|
| 6 |
+
click==8.1.8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
exceptiongroup==1.2.2
|
|
|
|
|
|
|
| 8 |
fastapi==0.115.6
|
| 9 |
+
ffmpy==0.5.0
|
| 10 |
filelock==3.16.1
|
| 11 |
+
fsspec==2024.12.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
gradio==5.9.1
|
| 13 |
gradio_client==1.5.2
|
| 14 |
h11==0.14.0
|
|
|
|
| 15 |
httpcore==1.0.7
|
| 16 |
httpx==0.28.1
|
|
|
|
| 17 |
huggingface-hub==0.27.0
|
|
|
|
| 18 |
idna==3.10
|
| 19 |
+
Jinja2==3.1.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
markdown-it-py==3.0.0
|
| 21 |
MarkupSafe==2.1.5
|
|
|
|
| 22 |
mdurl==0.1.2
|
| 23 |
+
numpy==2.2.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
orjson==3.10.12
|
| 25 |
packaging==24.2
|
| 26 |
pandas==2.2.3
|
| 27 |
+
pillow==11.0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
plotly==5.24.1
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
pydantic==2.10.4
|
| 30 |
pydantic_core==2.27.2
|
| 31 |
pydub==0.25.1
|
| 32 |
Pygments==2.18.0
|
|
|
|
|
|
|
|
|
|
| 33 |
python-dateutil==2.9.0.post0
|
| 34 |
python-multipart==0.0.20
|
|
|
|
|
|
|
| 35 |
pytz==2024.2
|
| 36 |
PyYAML==6.0.2
|
|
|
|
| 37 |
regex==2024.11.6
|
|
|
|
| 38 |
requests==2.32.3
|
|
|
|
| 39 |
rich==13.9.4
|
| 40 |
+
ruff==0.8.4
|
|
|
|
| 41 |
safehttpx==0.1.6
|
|
|
|
|
|
|
|
|
|
| 42 |
semantic-version==2.10.0
|
| 43 |
shellingham==1.5.4
|
| 44 |
six==1.17.0
|
| 45 |
sniffio==1.3.1
|
| 46 |
+
starlette==0.41.3
|
|
|
|
|
|
|
| 47 |
tenacity==9.0.0
|
| 48 |
+
tomlkit==0.13.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
tqdm==4.67.1
|
|
|
|
|
|
|
|
|
|
| 50 |
typer==0.15.1
|
| 51 |
typing_extensions==4.12.2
|
| 52 |
tzdata==2024.2
|
| 53 |
+
urllib3==2.3.0
|
| 54 |
uvicorn==0.34.0
|
| 55 |
+
websockets==14.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
serve/__pycache__/vote_utils.cpython-310.pyc
CHANGED
|
Binary files a/serve/__pycache__/vote_utils.cpython-310.pyc and b/serve/__pycache__/vote_utils.cpython-310.pyc differ
|
|
|
serve/vote_utils.py
CHANGED
|
@@ -7,17 +7,9 @@ import regex as re
|
|
| 7 |
from .utils import *
|
| 8 |
from .log_utils import build_logger
|
| 9 |
from .constants import IMAGE_DIR
|
| 10 |
-
from diffusers.utils import load_image
|
| 11 |
|
| 12 |
igm_logger = build_logger("gradio_web_server_image_generation_multi", "gr_web_image_generation_multi.log") # igm = image generation multi, loggers for side-by-side and battle
|
| 13 |
|
| 14 |
-
def save_any_image(image_file, file_path):
|
| 15 |
-
if isinstance(image_file, str):
|
| 16 |
-
image = load_image(image_file)
|
| 17 |
-
image.save(file_path, 'JPEG')
|
| 18 |
-
else:
|
| 19 |
-
image_file.save(file_path, 'JPEG')
|
| 20 |
-
|
| 21 |
|
| 22 |
def vote_last_response_igm(states, vote_type, anony, request: gr.Request):
|
| 23 |
with open(get_conv_log_filename(), "a") as fout:
|
|
@@ -186,238 +178,3 @@ class VideoStateVG:
|
|
| 186 |
"prompt": self.prompt
|
| 187 |
}
|
| 188 |
return base
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
def generate_igm(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
|
| 192 |
-
if not text:
|
| 193 |
-
raise gr.Warning("Prompt cannot be empty.")
|
| 194 |
-
if not model_name0:
|
| 195 |
-
raise gr.Warning("Model name A cannot be empty.")
|
| 196 |
-
if not model_name1:
|
| 197 |
-
raise gr.Warning("Model name B cannot be empty.")
|
| 198 |
-
state0 = ImageStateIG(model_name0)
|
| 199 |
-
state1 = ImageStateIG(model_name1)
|
| 200 |
-
ip = get_ip(request)
|
| 201 |
-
igm_logger.info(f"generate. ip: {ip}")
|
| 202 |
-
start_tstamp = time.time()
|
| 203 |
-
# Remove ### Model (A|B): from model name
|
| 204 |
-
model_name0 = re.sub(r"### Model A: ", "", model_name0)
|
| 205 |
-
model_name1 = re.sub(r"### Model B: ", "", model_name1)
|
| 206 |
-
generated_image0, generated_image1 = gen_func(text, model_name0, model_name1)
|
| 207 |
-
state0.prompt = text
|
| 208 |
-
state1.prompt = text
|
| 209 |
-
state0.output = generated_image0
|
| 210 |
-
state1.output = generated_image1
|
| 211 |
-
state0.model_name = model_name0
|
| 212 |
-
state1.model_name = model_name1
|
| 213 |
-
|
| 214 |
-
yield state0, state1, generated_image0, generated_image1
|
| 215 |
-
|
| 216 |
-
finish_tstamp = time.time()
|
| 217 |
-
# logger.info(f"===output===: {output}")
|
| 218 |
-
|
| 219 |
-
with open(get_conv_log_filename(), "a") as fout:
|
| 220 |
-
data = {
|
| 221 |
-
"tstamp": round(finish_tstamp, 4),
|
| 222 |
-
"type": "chat",
|
| 223 |
-
"model": model_name0,
|
| 224 |
-
"gen_params": {},
|
| 225 |
-
"start": round(start_tstamp, 4),
|
| 226 |
-
"finish": round(finish_tstamp, 4),
|
| 227 |
-
"state": state0.dict(),
|
| 228 |
-
"ip": get_ip(request),
|
| 229 |
-
}
|
| 230 |
-
fout.write(json.dumps(data) + "\n")
|
| 231 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 232 |
-
data = {
|
| 233 |
-
"tstamp": round(finish_tstamp, 4),
|
| 234 |
-
"type": "chat",
|
| 235 |
-
"model": model_name1,
|
| 236 |
-
"gen_params": {},
|
| 237 |
-
"start": round(start_tstamp, 4),
|
| 238 |
-
"finish": round(finish_tstamp, 4),
|
| 239 |
-
"state": state1.dict(),
|
| 240 |
-
"ip": get_ip(request),
|
| 241 |
-
}
|
| 242 |
-
fout.write(json.dumps(data) + "\n")
|
| 243 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 244 |
-
|
| 245 |
-
for i, state in enumerate([state0, state1]):
|
| 246 |
-
output_file = f'{IMAGE_DIR}/generation/{state.conv_id}.jpg'
|
| 247 |
-
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
| 248 |
-
with open(output_file, 'w') as f:
|
| 249 |
-
save_any_image(state.output, f)
|
| 250 |
-
save_image_file_on_log_server(output_file)
|
| 251 |
-
|
| 252 |
-
def generate_igm_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
|
| 253 |
-
if not model_name0:
|
| 254 |
-
raise gr.Warning("Model name A cannot be empty.")
|
| 255 |
-
if not model_name1:
|
| 256 |
-
raise gr.Warning("Model name B cannot be empty.")
|
| 257 |
-
state0 = ImageStateIG(model_name0)
|
| 258 |
-
state1 = ImageStateIG(model_name1)
|
| 259 |
-
ip = get_ip(request)
|
| 260 |
-
igm_logger.info(f"generate. ip: {ip}")
|
| 261 |
-
start_tstamp = time.time()
|
| 262 |
-
# Remove ### Model (A|B): from model name
|
| 263 |
-
model_name0 = re.sub(r"### Model A: ", "", model_name0)
|
| 264 |
-
model_name1 = re.sub(r"### Model B: ", "", model_name1)
|
| 265 |
-
generated_image0, generated_image1, text = gen_func(model_name0, model_name1)
|
| 266 |
-
state0.prompt = text
|
| 267 |
-
state1.prompt = text
|
| 268 |
-
state0.output = generated_image0
|
| 269 |
-
state1.output = generated_image1
|
| 270 |
-
state0.model_name = model_name0
|
| 271 |
-
state1.model_name = model_name1
|
| 272 |
-
|
| 273 |
-
yield state0, state1, generated_image0, generated_image1, text
|
| 274 |
-
|
| 275 |
-
finish_tstamp = time.time()
|
| 276 |
-
# logger.info(f"===output===: {output}")
|
| 277 |
-
|
| 278 |
-
with open(get_conv_log_filename(), "a") as fout:
|
| 279 |
-
data = {
|
| 280 |
-
"tstamp": round(finish_tstamp, 4),
|
| 281 |
-
"type": "chat",
|
| 282 |
-
"model": model_name0,
|
| 283 |
-
"gen_params": {},
|
| 284 |
-
"start": round(start_tstamp, 4),
|
| 285 |
-
"finish": round(finish_tstamp, 4),
|
| 286 |
-
"state": state0.dict(),
|
| 287 |
-
"ip": get_ip(request),
|
| 288 |
-
}
|
| 289 |
-
fout.write(json.dumps(data) + "\n")
|
| 290 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 291 |
-
data = {
|
| 292 |
-
"tstamp": round(finish_tstamp, 4),
|
| 293 |
-
"type": "chat",
|
| 294 |
-
"model": model_name1,
|
| 295 |
-
"gen_params": {},
|
| 296 |
-
"start": round(start_tstamp, 4),
|
| 297 |
-
"finish": round(finish_tstamp, 4),
|
| 298 |
-
"state": state1.dict(),
|
| 299 |
-
"ip": get_ip(request),
|
| 300 |
-
}
|
| 301 |
-
fout.write(json.dumps(data) + "\n")
|
| 302 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 303 |
-
|
| 304 |
-
for i, state in enumerate([state0, state1]):
|
| 305 |
-
output_file = f'{IMAGE_DIR}/generation/{state.conv_id}.jpg'
|
| 306 |
-
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
| 307 |
-
with open(output_file, 'w') as f:
|
| 308 |
-
save_any_image(state.output, f)
|
| 309 |
-
save_image_file_on_log_server(output_file)
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
def generate_igm_annoy(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
|
| 313 |
-
if not text:
|
| 314 |
-
raise gr.Warning("Prompt cannot be empty.")
|
| 315 |
-
state0 = ImageStateIG(model_name0)
|
| 316 |
-
state1 = ImageStateIG(model_name1)
|
| 317 |
-
ip = get_ip(request)
|
| 318 |
-
igm_logger.info(f"generate. ip: {ip}")
|
| 319 |
-
start_tstamp = time.time()
|
| 320 |
-
model_name0 = ""
|
| 321 |
-
model_name1 = ""
|
| 322 |
-
generated_image0, generated_image1, model_name0, model_name1 = gen_func(text, model_name0, model_name1)
|
| 323 |
-
state0.prompt = text
|
| 324 |
-
state1.prompt = text
|
| 325 |
-
state0.output = generated_image0
|
| 326 |
-
state1.output = generated_image1
|
| 327 |
-
state0.model_name = model_name0
|
| 328 |
-
state1.model_name = model_name1
|
| 329 |
-
|
| 330 |
-
yield state0, state1, generated_image0, generated_image1, \
|
| 331 |
-
gr.Markdown(f"### Model A: {model_name0}", visible=False), gr.Markdown(f"### Model B: {model_name1}", visible=False)
|
| 332 |
-
|
| 333 |
-
finish_tstamp = time.time()
|
| 334 |
-
# logger.info(f"===output===: {output}")
|
| 335 |
-
|
| 336 |
-
with open(get_conv_log_filename(), "a") as fout:
|
| 337 |
-
data = {
|
| 338 |
-
"tstamp": round(finish_tstamp, 4),
|
| 339 |
-
"type": "chat",
|
| 340 |
-
"model": model_name0,
|
| 341 |
-
"gen_params": {},
|
| 342 |
-
"start": round(start_tstamp, 4),
|
| 343 |
-
"finish": round(finish_tstamp, 4),
|
| 344 |
-
"state": state0.dict(),
|
| 345 |
-
"ip": get_ip(request),
|
| 346 |
-
}
|
| 347 |
-
fout.write(json.dumps(data) + "\n")
|
| 348 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 349 |
-
data = {
|
| 350 |
-
"tstamp": round(finish_tstamp, 4),
|
| 351 |
-
"type": "chat",
|
| 352 |
-
"model": model_name1,
|
| 353 |
-
"gen_params": {},
|
| 354 |
-
"start": round(start_tstamp, 4),
|
| 355 |
-
"finish": round(finish_tstamp, 4),
|
| 356 |
-
"state": state1.dict(),
|
| 357 |
-
"ip": get_ip(request),
|
| 358 |
-
}
|
| 359 |
-
fout.write(json.dumps(data) + "\n")
|
| 360 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 361 |
-
|
| 362 |
-
for i, state in enumerate([state0, state1]):
|
| 363 |
-
output_file = f'{IMAGE_DIR}/generation/{state.conv_id}.jpg'
|
| 364 |
-
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
| 365 |
-
with open(output_file, 'w') as f:
|
| 366 |
-
save_any_image(state.output, f)
|
| 367 |
-
save_image_file_on_log_server(output_file)
|
| 368 |
-
|
| 369 |
-
def generate_igm_annoy_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
|
| 370 |
-
state0 = ImageStateIG(model_name0)
|
| 371 |
-
state1 = ImageStateIG(model_name1)
|
| 372 |
-
ip = get_ip(request)
|
| 373 |
-
igm_logger.info(f"generate. ip: {ip}")
|
| 374 |
-
start_tstamp = time.time()
|
| 375 |
-
model_name0 = re.sub(r"### Model A: ", "", model_name0)
|
| 376 |
-
model_name1 = re.sub(r"### Model B: ", "", model_name1)
|
| 377 |
-
generated_image0, generated_image1, model_name0, model_name1, text = gen_func(model_name0, model_name1)
|
| 378 |
-
state0.prompt = text
|
| 379 |
-
state1.prompt = text
|
| 380 |
-
state0.output = generated_image0
|
| 381 |
-
state1.output = generated_image1
|
| 382 |
-
state0.model_name = model_name0
|
| 383 |
-
state1.model_name = model_name1
|
| 384 |
-
|
| 385 |
-
yield state0, state1, generated_image0, generated_image1, text,\
|
| 386 |
-
gr.Markdown(f"### Model A: {model_name0}"), gr.Markdown(f"### Model B: {model_name1}")
|
| 387 |
-
|
| 388 |
-
finish_tstamp = time.time()
|
| 389 |
-
# logger.info(f"===output===: {output}")
|
| 390 |
-
|
| 391 |
-
with open(get_conv_log_filename(), "a") as fout:
|
| 392 |
-
data = {
|
| 393 |
-
"tstamp": round(finish_tstamp, 4),
|
| 394 |
-
"type": "chat",
|
| 395 |
-
"model": model_name0,
|
| 396 |
-
"gen_params": {},
|
| 397 |
-
"start": round(start_tstamp, 4),
|
| 398 |
-
"finish": round(finish_tstamp, 4),
|
| 399 |
-
"state": state0.dict(),
|
| 400 |
-
"ip": get_ip(request),
|
| 401 |
-
}
|
| 402 |
-
fout.write(json.dumps(data) + "\n")
|
| 403 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 404 |
-
data = {
|
| 405 |
-
"tstamp": round(finish_tstamp, 4),
|
| 406 |
-
"type": "chat",
|
| 407 |
-
"model": model_name1,
|
| 408 |
-
"gen_params": {},
|
| 409 |
-
"start": round(start_tstamp, 4),
|
| 410 |
-
"finish": round(finish_tstamp, 4),
|
| 411 |
-
"state": state1.dict(),
|
| 412 |
-
"ip": get_ip(request),
|
| 413 |
-
}
|
| 414 |
-
fout.write(json.dumps(data) + "\n")
|
| 415 |
-
append_json_item_on_log_server(data, get_conv_log_filename())
|
| 416 |
-
|
| 417 |
-
for i, state in enumerate([state0, state1]):
|
| 418 |
-
output_file = f'{IMAGE_DIR}/generation/{state.conv_id}.jpg'
|
| 419 |
-
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
| 420 |
-
with open(output_file, 'w') as f:
|
| 421 |
-
save_any_image(state.output, f)
|
| 422 |
-
save_image_file_on_log_server(output_file)
|
| 423 |
-
|
|
|
|
| 7 |
from .utils import *
|
| 8 |
from .log_utils import build_logger
|
| 9 |
from .constants import IMAGE_DIR
|
|
|
|
| 10 |
|
| 11 |
igm_logger = build_logger("gradio_web_server_image_generation_multi", "gr_web_image_generation_multi.log") # igm = image generation multi, loggers for side-by-side and battle
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def vote_last_response_igm(states, vote_type, anony, request: gr.Request):
|
| 15 |
with open(get_conv_log_filename(), "a") as fout:
|
|
|
|
| 178 |
"prompt": self.prompt
|
| 179 |
}
|
| 180 |
return base
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|