Update app.py
Browse files
app.py
CHANGED
|
@@ -855,7 +855,7 @@ def roomItemClick(evt: gr.SelectData, seshid):
|
|
| 855 |
item_locator_data = [sesh.item_data_[sesh.current_img_signature][sesh.room_type][sesh.room_style][sesh.price][sesh.Palette_ids[sesh.current_img_signature]][data[1]][data[0]] for data in sesh.display_items_[sesh.current_img_signature] if data[1] not in ['Palette', 'Living Room', 'Bedroom']]
|
| 856 |
json_data = [json.dumps({'response': responses[i], 'item_locator_data': item_locator_data[i]}) for i,url in enumerate(urls)]
|
| 857 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 858 |
-
print('*-/*/-*-
|
| 859 |
|
| 860 |
formats = ['Youtube Long-Form', 'Youtube Short-Form', 'Facebook Long-Form', 'Instagram Reel', 'Tiktok', 'LinkedIn']
|
| 861 |
number_of_items = [7, 3, 7, 3, 3, 7]
|
|
@@ -881,9 +881,10 @@ def roomItemClick(evt: gr.SelectData, seshid):
|
|
| 881 |
json_data = [json.dumps({'video_format': fmt, 'number_of_items': number_of_items[i], 'idxs':idxs[i][:number_of_items[i]], 'room_type': sesh.room_type, 'item_locator_data': item_locator_data[i], 'gen_uid': sesh.frmt_id_maps[sesh.current_img_signature][formats[i]], 'seshid':seshid, 'items': items[i]}) for i,fmt in enumerate(formats) if process[i]]
|
| 882 |
urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for i in range(len(formats)) if process[i]]
|
| 883 |
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(formats) if process[i]]
|
|
|
|
| 884 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 885 |
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 886 |
-
print('*-/*/-*-
|
| 887 |
return gr.Column(scale=4), gr.update(visible=bool(0)), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.Gallery(visible=False), gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors'), gr.update(visible=bool(0)), seshid
|
| 888 |
elif selection in ['living room', 'bedroom']:
|
| 889 |
return gr.Column(scale=4), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.update(visible=bool(0)), gr.Gallery(visible=False), gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors', visible=True) if sesh.summary_closed else gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors', visible=False), gr.update(visible=bool(0)) if sesh.summary_closed else gr.update(visible=bool(1)), seshid
|
|
@@ -934,6 +935,48 @@ def replaceProduct(seshid):
|
|
| 934 |
|
| 935 |
#print('replaceProduct: ', sesh.product_idx, sesh.clicked_displayed_product, sesh.product_idx in sesh.inbudget[sesh.current_img_signature][sesh.clicked_displayed_product], sesh.display_items_, sum([float(item_product[1]['price'].replace('$', '').replace(',', '')) for img in sesh.summary for item_product in sesh.summary[img] if item_product]))
|
| 936 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 937 |
setSesh(seshid, sesh)
|
| 938 |
return gr.Column(scale=5), gr.update(visible=bool(0)), gr.update(visible=bool(0)), gr.update(visible=bool(0)), gr.Label('No Item Selected', label='Merchant'), gr.Gallery(visible=False), gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors', visible=True), gr.Gallery(sesh.updated_display, label='Room Items', columns=5)
|
| 939 |
|
|
|
|
| 855 |
item_locator_data = [sesh.item_data_[sesh.current_img_signature][sesh.room_type][sesh.room_style][sesh.price][sesh.Palette_ids[sesh.current_img_signature]][data[1]][data[0]] for data in sesh.display_items_[sesh.current_img_signature] if data[1] not in ['Palette', 'Living Room', 'Bedroom']]
|
| 856 |
json_data = [json.dumps({'response': responses[i], 'item_locator_data': item_locator_data[i]}) for i,url in enumerate(urls)]
|
| 857 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 858 |
+
print('*-/*/-*-roomItemClick: dumped store_shop: ', item_locator_data)
|
| 859 |
|
| 860 |
formats = ['Youtube Long-Form', 'Youtube Short-Form', 'Facebook Long-Form', 'Instagram Reel', 'Tiktok', 'LinkedIn']
|
| 861 |
number_of_items = [7, 3, 7, 3, 3, 7]
|
|
|
|
| 881 |
json_data = [json.dumps({'video_format': fmt, 'number_of_items': number_of_items[i], 'idxs':idxs[i][:number_of_items[i]], 'room_type': sesh.room_type, 'item_locator_data': item_locator_data[i], 'gen_uid': sesh.frmt_id_maps[sesh.current_img_signature][formats[i]], 'seshid':seshid, 'items': items[i]}) for i,fmt in enumerate(formats) if process[i]]
|
| 882 |
urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for i in range(len(formats)) if process[i]]
|
| 883 |
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(formats) if process[i]]
|
| 884 |
+
print('*-/*/-*-roomItemClick -- processed: ', len(json_data), [(f,process[i], idxs[i]) for i,f in enumerate(formats)])
|
| 885 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 886 |
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 887 |
+
print('*-/*/-*-roomItemClick: dumped scriptgen_promise: ', responses)
|
| 888 |
return gr.Column(scale=4), gr.update(visible=bool(0)), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.Gallery(visible=False), gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors'), gr.update(visible=bool(0)), seshid
|
| 889 |
elif selection in ['living room', 'bedroom']:
|
| 890 |
return gr.Column(scale=4), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.update(visible=bool(0)), gr.Gallery(visible=False), gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors', visible=True) if sesh.summary_closed else gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors', visible=False), gr.update(visible=bool(0)) if sesh.summary_closed else gr.update(visible=bool(1)), seshid
|
|
|
|
| 935 |
|
| 936 |
#print('replaceProduct: ', sesh.product_idx, sesh.clicked_displayed_product, sesh.product_idx in sesh.inbudget[sesh.current_img_signature][sesh.clicked_displayed_product], sesh.display_items_, sum([float(item_product[1]['price'].replace('$', '').replace(',', '')) for img in sesh.summary for item_product in sesh.summary[img] if item_product]))
|
| 937 |
|
| 938 |
+
if True:
|
| 939 |
+
urls = [sesh.item_data[sesh.current_img_signature][sesh.item_data_keys[sesh.current_img_signature]['room_type']][sesh.item_data_keys[sesh.current_img_signature]['room_style']][sesh.item_data_keys[sesh.current_img_signature]['price']][sesh.item_data_keys[sesh.current_img_signature]['Paletteid']][itemidx_item[1]][itemidx_item[0]]['href'] for itemidx_item in sesh.display_items_[sesh.current_img_signature] if itemidx_item[1] not in ['Palette', 'Living Room', 'Bedroom']]
|
| 940 |
+
sesh.responses = asyncio.run(main(urls))
|
| 941 |
+
urls = ['https://dreamdemo.pythonanywhere.com/store_shop' for _ in range(len(urls))]
|
| 942 |
+
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
| 943 |
+
responses = [r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses]
|
| 944 |
+
item_locator_data = [sesh.item_data_[sesh.current_img_signature][sesh.room_type][sesh.room_style][sesh.price][sesh.Palette_ids[sesh.current_img_signature]][data[1]][data[0]] for data in sesh.display_items_[sesh.current_img_signature] if data[1] not in ['Palette', 'Living Room', 'Bedroom']]
|
| 945 |
+
json_data = [json.dumps({'response': responses[i], 'item_locator_data': item_locator_data[i]}) for i,url in enumerate(urls)]
|
| 946 |
+
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 947 |
+
print('*-/*/-*-roomItemClick: dumped store_shop: ', item_locator_data)
|
| 948 |
+
|
| 949 |
+
formats = ['Youtube Long-Form', 'Youtube Short-Form', 'Facebook Long-Form', 'Instagram Reel', 'Tiktok', 'LinkedIn']
|
| 950 |
+
number_of_items = [7, 3, 7, 3, 3, 7]
|
| 951 |
+
urls = [sesh.item_data[sesh.current_img_signature][sesh.item_data_keys[sesh.current_img_signature]['room_type']][sesh.item_data_keys[sesh.current_img_signature]['room_style']][sesh.item_data_keys[sesh.current_img_signature]['price']][sesh.item_data_keys[sesh.current_img_signature]['Paletteid']][itemidx_item[1]][itemidx_item[0]]['href'] for itemidx_item in sesh.display_items_[sesh.current_img_signature] if itemidx_item[1] not in ['Palette', 'Living Room', 'Bedroom']]
|
| 952 |
+
sesh.responses = asyncio.run(main(urls))
|
| 953 |
+
#urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for _ in range(len(formats))]
|
| 954 |
+
#headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
| 955 |
+
responses = [[r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses] for _ in range(len(formats))]
|
| 956 |
+
item_locator_data = [[sesh.item_data_[sesh.current_img_signature][sesh.room_type][sesh.room_style][sesh.price][sesh.Palette_ids[sesh.current_img_signature]][data[1]][data[0]] for data in sesh.display_items_[sesh.current_img_signature] if data[1] not in ['Palette', 'Living Room', 'Bedroom']] for _ in range(len(formats))]
|
| 957 |
+
items = [[data[1] for data in sesh.display_items_[sesh.current_img_signature] if data[1] not in ['Palette', 'Living Room', 'Bedroom']] for _ in range(len(formats))]
|
| 958 |
+
idxs = [list(range(len(items))) for i,_ in enumerate(formats)]
|
| 959 |
+
process = {}
|
| 960 |
+
for i,_ in enumerate(formats):
|
| 961 |
+
if formats[i] in sesh.frmt_idxs_maps[sesh.current_img_signature] and all([tupe in item_locator_data[0] for tupe in sesh.frmt_idxs_maps[sesh.current_img_signature][formats[i]]]):
|
| 962 |
+
process[i] = False
|
| 963 |
+
np.random.shuffle(idxs[i])
|
| 964 |
+
idxs[i] = idxs[i][:number_of_items[i]]
|
| 965 |
+
sesh.frmt_idxs_maps[sesh.current_img_signature][formats[i]] = [item_locator_data[i][idx] for idx in idxs[i]]
|
| 966 |
+
sesh.frmt_id_maps[sesh.current_img_signature][formats[i]] = str(time.time())
|
| 967 |
+
process[i] = True
|
| 968 |
+
time.sleep(.001)
|
| 969 |
+
json_data = [json.dumps({'video_format': fmt, 'number_of_items': number_of_items[i], 'idxs':idxs[i][:number_of_items[i]], 'room_type': sesh.room_type, 'item_locator_data': item_locator_data[i], 'gen_uid': sesh.frmt_id_maps[sesh.current_img_signature][formats[i]], 'seshid':seshid, 'items': items[i]}) for i,fmt in enumerate(formats) if process[i]]
|
| 970 |
+
urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for i in range(len(formats)) if process[i]]
|
| 971 |
+
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(formats) if process[i]]
|
| 972 |
+
print('*-/*/-*-roomItemClick -- processed: ', len(json_data), [(f,process[i], idxs[i]) for i,f in enumerate(formats)])
|
| 973 |
+
if json_data:
|
| 974 |
+
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 975 |
+
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 976 |
+
else:
|
| 977 |
+
responses = []
|
| 978 |
+
print('*-/*/-*-roomItemClick: dumped scriptgen_promise: ', responses)
|
| 979 |
+
|
| 980 |
setSesh(seshid, sesh)
|
| 981 |
return gr.Column(scale=5), gr.update(visible=bool(0)), gr.update(visible=bool(0)), gr.update(visible=bool(0)), gr.Label('No Item Selected', label='Merchant'), gr.Gallery(visible=False), gr.Label('Dream Home: As Quick As A Click. As Simple As Shopping.', label='Sponsors', visible=True), gr.Gallery(sesh.updated_display, label='Room Items', columns=5)
|
| 982 |
|