Update app.py
Browse files
app.py
CHANGED
|
@@ -576,7 +576,7 @@ def updateItemDisplay(seshid, budget=False, pallete_change=False):
|
|
| 576 |
room_type = content['room_type']
|
| 577 |
video_format = content['video_format']"""
|
| 578 |
|
| 579 |
-
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']]
|
| 580 |
sesh.responses = asyncio.run(main(urls))
|
| 581 |
urls = ['https://dreamdemo.pythonanywhere.com/store_shop' for _ in range(len(urls))]
|
| 582 |
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
|
@@ -606,7 +606,7 @@ def updateItemDisplay(seshid, budget=False, pallete_change=False):
|
|
| 606 |
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)]
|
| 607 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 608 |
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 609 |
-
print('*-/*/-*-updateDisplay: dumped scriptgen_promise: ', responses)
|
| 610 |
|
| 611 |
setSesh(seshid, sesh)
|
| 612 |
return gr.Gallery(realised_display, label='Room Items', columns=5)
|
|
@@ -847,6 +847,37 @@ def roomItemClick(evt: gr.SelectData, seshid):
|
|
| 847 |
sesh.clicked_displayed_product = evt.value['caption']
|
| 848 |
setSesh(seshid, sesh)
|
| 849 |
if selection == 'palette':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 850 |
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
|
| 851 |
elif selection in ['living room', 'bedroom']:
|
| 852 |
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
|
|
|
|
| 576 |
room_type = content['room_type']
|
| 577 |
video_format = content['video_format']"""
|
| 578 |
|
| 579 |
+
"""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']]
|
| 580 |
sesh.responses = asyncio.run(main(urls))
|
| 581 |
urls = ['https://dreamdemo.pythonanywhere.com/store_shop' for _ in range(len(urls))]
|
| 582 |
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
|
|
|
| 606 |
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)]
|
| 607 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 608 |
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 609 |
+
print('*-/*/-*-updateDisplay: dumped scriptgen_promise: ', responses)"""
|
| 610 |
|
| 611 |
setSesh(seshid, sesh)
|
| 612 |
return gr.Gallery(realised_display, label='Room Items', columns=5)
|
|
|
|
| 847 |
sesh.clicked_displayed_product = evt.value['caption']
|
| 848 |
setSesh(seshid, sesh)
|
| 849 |
if selection == 'palette':
|
| 850 |
+
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']]
|
| 851 |
+
sesh.responses = asyncio.run(main(urls))
|
| 852 |
+
urls = ['https://dreamdemo.pythonanywhere.com/store_shop' for _ in range(len(urls))]
|
| 853 |
+
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
| 854 |
+
responses = [r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses]
|
| 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('*-/*/-*-updateDisplay: 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]
|
| 862 |
+
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']]
|
| 863 |
+
sesh.responses = asyncio.run(main(urls))
|
| 864 |
+
urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for _ in range(len(formats))]
|
| 865 |
+
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
| 866 |
+
responses = [[r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses] for _ in range(len(formats))]
|
| 867 |
+
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))]
|
| 868 |
+
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))]
|
| 869 |
+
idxs = [list(range(len(items))) for i,_ in enumerate(formats)]
|
| 870 |
+
for i,_ in enumerate(formats):
|
| 871 |
+
np.random.shuffle(idxs[i])
|
| 872 |
+
idxs[i] = idxs[i][:number_of_items[i]]
|
| 873 |
+
sesh.frmt_idxs_maps[sesh.current_img_signature][formats[i]] = [item_locator_data[i][idx] for idx in idxs[i]]
|
| 874 |
+
sesh.frmt_id_maps[sesh.current_img_signature][formats[i]] = str(time.time())
|
| 875 |
+
time.sleep(.001)
|
| 876 |
+
#json_data = [json.dumps({'video_format': fmt, 'number_of_items': number_of_items[i], 'room_type': sesh.room_type, 'item_locator_data': item_locator_data, 'gen_uid': i, 'responses':responses, 'items': items}) for i,fmt in enumerate(formats)]
|
| 877 |
+
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)]
|
| 878 |
+
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 879 |
+
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 880 |
+
print('*-/*/-*-updateDisplay: dumped scriptgen_promise: ', responses)
|
| 881 |
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
|
| 882 |
elif selection in ['living room', 'bedroom']:
|
| 883 |
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
|