Spaces:
Build error
Build error
aswin-raghavan commited on
Commit ·
9b18ee8
1
Parent(s): 3057f69
add more randomness
Browse files
app.py
CHANGED
|
@@ -6,7 +6,8 @@ from PIL import Image
|
|
| 6 |
from transformers import CLIPProcessor, CLIPModel
|
| 7 |
import pandas as pd
|
| 8 |
from glob import glob
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
| 12 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
|
@@ -31,6 +32,7 @@ def update_table(img, img_name, df, state, label):
|
|
| 31 |
print(new_df)
|
| 32 |
df = pd.concat([df, new_df])
|
| 33 |
state.pop()
|
|
|
|
| 34 |
idx = -1 # choice(len(state))
|
| 35 |
next_img = state[idx]
|
| 36 |
# state.pop(idx)
|
|
@@ -44,13 +46,14 @@ def update_table_down(img, img_name, df, state):
|
|
| 44 |
|
| 45 |
def get_random_image(state):
|
| 46 |
print(state)
|
| 47 |
-
idx = choice(len(state))
|
| 48 |
return state[idx], state[idx]
|
| 49 |
|
| 50 |
|
| 51 |
with gr.Blocks(title="End-User Personalization") as demo:
|
| 52 |
img_list = glob('images/**/*.jpg')
|
| 53 |
-
|
|
|
|
| 54 |
images = gr.State(img_list)
|
| 55 |
# start_button = gr.Button(label="Start")
|
| 56 |
image_display = gr.Image()
|
|
|
|
| 6 |
from transformers import CLIPProcessor, CLIPModel
|
| 7 |
import pandas as pd
|
| 8 |
from glob import glob
|
| 9 |
+
import random
|
| 10 |
+
from datetime import datetime
|
| 11 |
|
| 12 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
| 13 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
|
|
|
| 32 |
print(new_df)
|
| 33 |
df = pd.concat([df, new_df])
|
| 34 |
state.pop()
|
| 35 |
+
random.shuffle(state)
|
| 36 |
idx = -1 # choice(len(state))
|
| 37 |
next_img = state[idx]
|
| 38 |
# state.pop(idx)
|
|
|
|
| 46 |
|
| 47 |
def get_random_image(state):
|
| 48 |
print(state)
|
| 49 |
+
idx = random.choice(len(state))
|
| 50 |
return state[idx], state[idx]
|
| 51 |
|
| 52 |
|
| 53 |
with gr.Blocks(title="End-User Personalization") as demo:
|
| 54 |
img_list = glob('images/**/*.jpg')
|
| 55 |
+
random.seed(datetime.now().timestamp())
|
| 56 |
+
random.shuffle(img_list)
|
| 57 |
images = gr.State(img_list)
|
| 58 |
# start_button = gr.Button(label="Start")
|
| 59 |
image_display = gr.Image()
|