Spaces:
Build error
Build error
aswin-raghavan commited on
Commit ·
95ceb1c
1
Parent(s): 05a5128
reduce shuffle time
Browse files
app.py
CHANGED
|
@@ -32,10 +32,11 @@ def update_table(img, img_name, df, state, label):
|
|
| 32 |
print(new_df)
|
| 33 |
df = pd.concat([df, new_df])
|
| 34 |
state.pop()
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
next_img = state[idx]
|
| 38 |
-
# state.pop(idx)
|
| 39 |
return next_img, next_img, df, state
|
| 40 |
|
| 41 |
def update_table_up(img, img_name, df, state):
|
|
@@ -44,11 +45,6 @@ def update_table_up(img, img_name, df, state):
|
|
| 44 |
def update_table_down(img, img_name, df, state):
|
| 45 |
return update_table(img, img_name, df, state, 0)
|
| 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')
|
|
@@ -66,15 +62,6 @@ with gr.Blocks(title="End-User Personalization") as demo:
|
|
| 66 |
col_count=(3, 'fixed'), label='Annotations', wrap=False)
|
| 67 |
upvote.click(update_table_up, inputs=[image_display, image_fname, annotated_samples, images], outputs=[image_display, image_fname, annotated_samples, images])
|
| 68 |
downvote.click(update_table_down, inputs=[image_display, image_fname, annotated_samples, images], outputs=[image_display, image_fname, annotated_samples, images])
|
| 69 |
-
# examples = gr.Examples(examples=[["dog.jpg"], ["colombia.jpg"], ["germany.jpg"]], inputs=[image_display])
|
| 70 |
|
| 71 |
-
# iface = gr.Interface(shot,
|
| 72 |
-
# ["image", "text"],
|
| 73 |
-
# "text",
|
| 74 |
-
# examples=[["dog.jpg", "dog,cat,bird,animal"],
|
| 75 |
-
# # ["germany.jpg", "germany,belgium,colombia"],
|
| 76 |
-
# ["colombia.jpg", "germany,belgium,colombia"]],
|
| 77 |
-
# description="Add a picture and a list of labels separated by commas",
|
| 78 |
-
# title="CLIP feature extractor")
|
| 79 |
demo.load(lambda: (images.value[-1], images.value[-1]), inputs=[], outputs=[image_display, image_fname])
|
| 80 |
demo.launch(show_error=True, debug=True)
|
|
|
|
| 32 |
print(new_df)
|
| 33 |
df = pd.concat([df, new_df])
|
| 34 |
state.pop()
|
| 35 |
+
t = state[-10:]
|
| 36 |
+
random.shuffle(t)
|
| 37 |
+
state = state[:-10] + t
|
| 38 |
+
idx = -1
|
| 39 |
next_img = state[idx]
|
|
|
|
| 40 |
return next_img, next_img, df, state
|
| 41 |
|
| 42 |
def update_table_up(img, img_name, df, state):
|
|
|
|
| 45 |
def update_table_down(img, img_name, df, state):
|
| 46 |
return update_table(img, img_name, df, state, 0)
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
with gr.Blocks(title="End-User Personalization") as demo:
|
| 50 |
img_list = glob('images/**/*.jpg')
|
|
|
|
| 62 |
col_count=(3, 'fixed'), label='Annotations', wrap=False)
|
| 63 |
upvote.click(update_table_up, inputs=[image_display, image_fname, annotated_samples, images], outputs=[image_display, image_fname, annotated_samples, images])
|
| 64 |
downvote.click(update_table_down, inputs=[image_display, image_fname, annotated_samples, images], outputs=[image_display, image_fname, annotated_samples, images])
|
|
|
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
demo.load(lambda: (images.value[-1], images.value[-1]), inputs=[], outputs=[image_display, image_fname])
|
| 67 |
demo.launch(show_error=True, debug=True)
|