yonatanbitton commited on
Commit
01c1744
·
1 Parent(s): 75812ad

first commit

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -6,6 +6,7 @@ whoops = load_dataset("nlphuji/whoops")['test']
6
  BUCKET_PATH = 'https://wmtis.s3.eu-west-1.amazonaws.com/wmtis_images'
7
 
8
  df = whoops.to_pandas()
 
9
  df = df.sample(frac=1)
10
  def get_image_url(img_id):
11
  return f"{BUCKET_PATH}/{img_id}.png"
@@ -36,9 +37,17 @@ def display_df():
36
  return df_images
37
 
38
  def display_next(dataframe, end):
39
- start = (end or dataframe.index[-1]) + 1
40
- end = start + (LINES_NUMBER-1)
41
- df_images = df.loc[start:end]
 
 
 
 
 
 
 
 
42
  return df_images, end
43
 
44
  # Gradio Blocks
 
6
  BUCKET_PATH = 'https://wmtis.s3.eu-west-1.amazonaws.com/wmtis_images'
7
 
8
  df = whoops.to_pandas()
9
+ print(f"Got {len(df)} items in dataframe")
10
  df = df.sample(frac=1)
11
  def get_image_url(img_id):
12
  return f"{BUCKET_PATH}/{img_id}.png"
 
37
  return df_images
38
 
39
  def display_next(dataframe, end):
40
+ start = int(end or len(dataframe))
41
+ end = int(start) + int(LINES_NUMBER)
42
+ global df
43
+ if end >= len(df) - 1:
44
+ start = 0
45
+ end = LINES_NUMBER
46
+ df = df.sample(frac=1)
47
+ print(f"Shuffeling")
48
+ print(f"end: {end},start: {start}")
49
+ df_images = df.iloc[start:end]
50
+ assert len(df_images) == LINES_NUMBER
51
  return df_images, end
52
 
53
  # Gradio Blocks