Spaces:
Running
Running
Update app.py
Browse filesAdded HD image stats
app.py
CHANGED
|
@@ -101,6 +101,7 @@ def genUsageStats(do_reset=False):
|
|
| 101 |
totalAudio = 0
|
| 102 |
totalSpeech = 0
|
| 103 |
totalImages = 0
|
|
|
|
| 104 |
if do_reset:
|
| 105 |
dudPath = dataDir + '_speech.txt'
|
| 106 |
if os.path.exists(dudPath):
|
|
@@ -185,6 +186,7 @@ def genUsageStats(do_reset=False):
|
|
| 185 |
if not accessOk:
|
| 186 |
return f'File access failed reading speech stats for user: {user}'
|
| 187 |
user_images = 0
|
|
|
|
| 188 |
fp = image_count_path(user)
|
| 189 |
if os.path.exists(fp):
|
| 190 |
accessOk = False
|
|
@@ -196,17 +198,21 @@ def genUsageStats(do_reset=False):
|
|
| 196 |
os.remove(fp)
|
| 197 |
else:
|
| 198 |
for line in dataList:
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
accessOk = True
|
| 203 |
break
|
| 204 |
except:
|
| 205 |
sleep(3)
|
| 206 |
if not accessOk:
|
| 207 |
return f'File access failed reading image gen stats for user: {user}'
|
| 208 |
-
result.append([user, f'{tokens4mini_in}/{tokens4mini_out}', f'{tokens4o_in}/{tokens4o_out}', f'audio:{userAudio}',f'speech:{userSpeech}', f'images:{user_images}'])
|
| 209 |
-
result.append(['totals', f'{ttotal4mini_in}/{ttotal4mini_out}', f'{ttotal4o_in}/{ttotal4o_out}', f'audio:{totalAudio}',f'speech:{totalSpeech}', f'images:{totalImages}'])
|
| 210 |
return result
|
| 211 |
|
| 212 |
def new_conversation(user):
|
|
@@ -452,7 +458,10 @@ def make_image(prompt, user, pwd):
|
|
| 452 |
fpath = dataDir + user + '.png'
|
| 453 |
image.save(fpath)
|
| 454 |
with open(image_count_path(user), 'at') as fp:
|
| 455 |
-
|
|
|
|
|
|
|
|
|
|
| 456 |
msg = 'Image created!'
|
| 457 |
except:
|
| 458 |
return [gr.Image(visible=False, value=None), msg]
|
|
|
|
| 101 |
totalAudio = 0
|
| 102 |
totalSpeech = 0
|
| 103 |
totalImages = 0
|
| 104 |
+
totalHdImages = 0
|
| 105 |
if do_reset:
|
| 106 |
dudPath = dataDir + '_speech.txt'
|
| 107 |
if os.path.exists(dudPath):
|
|
|
|
| 186 |
if not accessOk:
|
| 187 |
return f'File access failed reading speech stats for user: {user}'
|
| 188 |
user_images = 0
|
| 189 |
+
user_hd_images = 0
|
| 190 |
fp = image_count_path(user)
|
| 191 |
if os.path.exists(fp):
|
| 192 |
accessOk = False
|
|
|
|
| 198 |
os.remove(fp)
|
| 199 |
else:
|
| 200 |
for line in dataList:
|
| 201 |
+
x = line.strip()
|
| 202 |
+
if x == 'hd':
|
| 203 |
+
user_hd_images += 1
|
| 204 |
+
totalHdImages += 1
|
| 205 |
+
else:
|
| 206 |
+
user_images += 1
|
| 207 |
+
totalImages += 1
|
| 208 |
accessOk = True
|
| 209 |
break
|
| 210 |
except:
|
| 211 |
sleep(3)
|
| 212 |
if not accessOk:
|
| 213 |
return f'File access failed reading image gen stats for user: {user}'
|
| 214 |
+
result.append([user, f'{tokens4mini_in}/{tokens4mini_out}', f'{tokens4o_in}/{tokens4o_out}', f'audio:{userAudio}',f'speech:{userSpeech}', f'images:{user_images}/{user_hd_images}'])
|
| 215 |
+
result.append(['totals', f'{ttotal4mini_in}/{ttotal4mini_out}', f'{ttotal4o_in}/{ttotal4o_out}', f'audio:{totalAudio}',f'speech:{totalSpeech}', f'images:{totalImages}/{totalHdImages}'])
|
| 216 |
return result
|
| 217 |
|
| 218 |
def new_conversation(user):
|
|
|
|
| 458 |
fpath = dataDir + user + '.png'
|
| 459 |
image.save(fpath)
|
| 460 |
with open(image_count_path(user), 'at') as fp:
|
| 461 |
+
if quality == 'hd':
|
| 462 |
+
fp.write('hd')
|
| 463 |
+
else:
|
| 464 |
+
fp.write('1\n')
|
| 465 |
msg = 'Image created!'
|
| 466 |
except:
|
| 467 |
return [gr.Image(visible=False, value=None), msg]
|