Update app.py
Browse files
app.py
CHANGED
|
@@ -836,6 +836,48 @@ def applyStyle(evt: gr.SelectData, seshid):
|
|
| 836 |
return gr.Gallery(room_items_imgs_tuples, label='Room Items', columns=5)
|
| 837 |
|
| 838 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 839 |
def roomItemClick(evt: gr.SelectData, seshid):
|
| 840 |
sesh = getSesh(seshid)
|
| 841 |
if 'SESHID' in all_sesh.sessions:
|
|
@@ -847,7 +889,7 @@ def roomItemClick(evt: gr.SelectData, seshid):
|
|
| 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)]
|
|
@@ -884,7 +926,7 @@ def roomItemClick(evt: gr.SelectData, seshid):
|
|
| 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
|
|
|
|
| 836 |
return gr.Gallery(room_items_imgs_tuples, label='Room Items', columns=5)
|
| 837 |
|
| 838 |
|
| 839 |
+
def dummyFrmt(frmt):
|
| 840 |
+
if True:
|
| 841 |
+
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']]
|
| 842 |
+
sesh.responses = asyncio.run(main(urls))
|
| 843 |
+
urls = ['https://dreamdemo.pythonanywhere.com/store_shop' for _ in range(len(urls))]
|
| 844 |
+
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
| 845 |
+
responses = [r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses]
|
| 846 |
+
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']]
|
| 847 |
+
json_data = [json.dumps({'response': responses[i], 'item_locator_data': item_locator_data[i]}) for i,url in enumerate(urls)]
|
| 848 |
+
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 849 |
+
print('*-/*/-*-roomItemClick: dumped store_shop: ', item_locator_data)
|
| 850 |
+
|
| 851 |
+
formats = ['Youtube Long-Form', 'Youtube Short-Form', 'Facebook Long-Form', 'Instagram Reel', 'Tiktok', 'LinkedIn']
|
| 852 |
+
formats = [frmt]
|
| 853 |
+
number_of_items = [7, 3, 7, 3, 3, 7]
|
| 854 |
+
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']]
|
| 855 |
+
sesh.responses = asyncio.run(main(urls))
|
| 856 |
+
#urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for _ in range(len(formats))]
|
| 857 |
+
#headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
| 858 |
+
responses = [[r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses] for _ in range(len(formats))]
|
| 859 |
+
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))]
|
| 860 |
+
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))]
|
| 861 |
+
idxs = [list(range(len(items))) for i,_ in enumerate(formats)]
|
| 862 |
+
process = {}
|
| 863 |
+
for i,_ in enumerate(formats):
|
| 864 |
+
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]]]):
|
| 865 |
+
process[i] = False
|
| 866 |
+
np.random.shuffle(idxs[i])
|
| 867 |
+
idxs[i] = idxs[i][:number_of_items[i]]
|
| 868 |
+
sesh.frmt_idxs_maps[sesh.current_img_signature][formats[i]] = [item_locator_data[i][idx] for idx in idxs[i]]
|
| 869 |
+
sesh.frmt_id_maps[sesh.current_img_signature][formats[i]] = str(time.time())
|
| 870 |
+
process[i] = True
|
| 871 |
+
time.sleep(.001)
|
| 872 |
+
#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)]
|
| 873 |
+
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]]
|
| 874 |
+
urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for i in range(len(formats)) if process[i]]
|
| 875 |
+
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(formats) if process[i]]
|
| 876 |
+
print('*-/*/-*-roomItemClick -- processed: ', len(json_data), [(f,process[i], idxs[i]) for i,f in enumerate(formats)])
|
| 877 |
+
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 878 |
+
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 879 |
+
print('*-/*/-*-roomItemClick: dumped scriptgen_promise: ', responses)
|
| 880 |
+
|
| 881 |
def roomItemClick(evt: gr.SelectData, seshid):
|
| 882 |
sesh = getSesh(seshid)
|
| 883 |
if 'SESHID' in all_sesh.sessions:
|
|
|
|
| 889 |
sesh.clicked_displayed_product = evt.value['caption']
|
| 890 |
setSesh(seshid, sesh)
|
| 891 |
if selection == 'palette':
|
| 892 |
+
"""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']]
|
| 893 |
sesh.responses = asyncio.run(main(urls))
|
| 894 |
urls = ['https://dreamdemo.pythonanywhere.com/store_shop' for _ in range(len(urls))]
|
| 895 |
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
|
|
|
|
| 926 |
print('*-/*/-*-roomItemClick -- processed: ', len(json_data), [(f,process[i], idxs[i]) for i,f in enumerate(formats)])
|
| 927 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 928 |
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 929 |
+
print('*-/*/-*-roomItemClick: dumped scriptgen_promise: ', responses)"""
|
| 930 |
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
|
| 931 |
elif selection in ['living room', 'bedroom']:
|
| 932 |
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
|