ysharma HF staff commited on
Commit
a494deb
·
verified ·
1 Parent(s): e97c8c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -9
app.py CHANGED
@@ -6,15 +6,14 @@ import requests
6
  API_URL_INITIAL = "https://ysharma-playground-ai-exploration.hf.space/run/initial_dataframe"
7
  API_URL_NEXT10 = "https://ysharma-playground-ai-exploration.hf.space/run/next_10_rows"
8
 
9
- #define inference function
10
  #First: Get initial images for the grid display
11
  def get_initial_images():
12
  response = requests.post(API_URL_INITIAL, json={
13
  "data": []
14
  }).json()
15
- #data = response["data"][0]['data'][0][0][:-1]
16
  response_dict = response['data'][0]
17
- return response_dict #, [resp[0][:-1] for resp in response["data"][0]["data"]]
18
 
19
  #Second: Process response dictionary to get imges as hyperlinked image tags
20
  def process_response(response_dict):
@@ -27,7 +26,6 @@ initial_imgs = '<div style="display: grid; grid-template-columns: repeat(3, 1fr
27
  #Third: Load more images for the grid
28
  def get_next10_images(response_dict, row_count):
29
  row_count = int(row_count)
30
- #print("(1)",type(response_dict))
31
  #Convert the string to a dictionary
32
  if isinstance(response_dict, dict) == False :
33
  response_dict = ast.literal_eval(response_dict)
@@ -36,15 +34,10 @@ def get_next10_images(response_dict, row_count):
36
  }).json()
37
  row_count+=10
38
  response_dict = response['data'][0]
39
- #print("(2)",type(response))
40
- #print("(3)",type(response['data'][0]))
41
  next_set = [resp[0][:-1] for resp in response_dict["data"]]
42
  next_set_images = '<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 0; background-color: #fff; padding: 20px; box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); ">\n' + "\n".join(next_set[:-1])
43
  return response_dict, row_count, next_set_images #response['data'][0]
44
 
45
- #get_next10_images(response_dict=response_dict, row_count=9)
46
- #position: fixed; top: 0; left: 0; width: 100%; background-color: #fff; padding: 20px; box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
47
-
48
  #Defining the Blocks layout
49
  with gr.Blocks(css = """#img_search img {width: 100%; height: 100%; object-fit: cover;}""") as demo:
50
  gr.HTML(value="top of page", elem_id="top",visible=False)
 
6
  API_URL_INITIAL = "https://ysharma-playground-ai-exploration.hf.space/run/initial_dataframe"
7
  API_URL_NEXT10 = "https://ysharma-playground-ai-exploration.hf.space/run/next_10_rows"
8
 
9
+ #Define inference function
10
  #First: Get initial images for the grid display
11
  def get_initial_images():
12
  response = requests.post(API_URL_INITIAL, json={
13
  "data": []
14
  }).json()
 
15
  response_dict = response['data'][0]
16
+ return response_dict
17
 
18
  #Second: Process response dictionary to get imges as hyperlinked image tags
19
  def process_response(response_dict):
 
26
  #Third: Load more images for the grid
27
  def get_next10_images(response_dict, row_count):
28
  row_count = int(row_count)
 
29
  #Convert the string to a dictionary
30
  if isinstance(response_dict, dict) == False :
31
  response_dict = ast.literal_eval(response_dict)
 
34
  }).json()
35
  row_count+=10
36
  response_dict = response['data'][0]
 
 
37
  next_set = [resp[0][:-1] for resp in response_dict["data"]]
38
  next_set_images = '<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 0; background-color: #fff; padding: 20px; box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); ">\n' + "\n".join(next_set[:-1])
39
  return response_dict, row_count, next_set_images #response['data'][0]
40
 
 
 
 
41
  #Defining the Blocks layout
42
  with gr.Blocks(css = """#img_search img {width: 100%; height: 100%; object-fit: cover;}""") as demo:
43
  gr.HTML(value="top of page", elem_id="top",visible=False)