Update app.py
Browse files
app.py
CHANGED
|
@@ -944,7 +944,7 @@ def replaceProduct(seshid):
|
|
| 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('*-/*/-*-
|
| 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]
|
|
@@ -958,6 +958,7 @@ def replaceProduct(seshid):
|
|
| 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])
|
|
@@ -969,13 +970,13 @@ def replaceProduct(seshid):
|
|
| 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('*-/*/-*-
|
| 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('*-/*/-*-
|
| 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)
|
|
|
|
| 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('*-/*/-*-replaceProduct: 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]
|
|
|
|
| 958 |
idxs = [list(range(len(items))) for i,_ in enumerate(formats)]
|
| 959 |
process = {}
|
| 960 |
for i,_ in enumerate(formats):
|
| 961 |
+
print('*-/*/-*-replaceProduct -- prep: ', formats[i], formats[i] in sesh.frmt_idxs_maps, sesh.frmt_idxs_maps[sesh.current_img_signature][formats[i]] if formats[i] in sesh.frmt_idxs_maps else None, item_locator_data[0])
|
| 962 |
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]]]):
|
| 963 |
process[i] = False
|
| 964 |
np.random.shuffle(idxs[i])
|
|
|
|
| 970 |
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]]
|
| 971 |
urls = ['https://dreamdemo.pythonanywhere.com/scriptgen_promise' for i in range(len(formats)) if process[i]]
|
| 972 |
headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(formats) if process[i]]
|
| 973 |
+
print('*-/*/-*-replaceProduct -- processed: ', len(json_data), [(f,process[i], idxs[i]) for i,f in enumerate(formats)])
|
| 974 |
if json_data:
|
| 975 |
responses = asyncio.run(main_post(urls, headers, json_data, timeout=.5))
|
| 976 |
#responses = asyncio.run(main_post(urls, headers, json_data, timeout=3))
|
| 977 |
else:
|
| 978 |
responses = []
|
| 979 |
+
print('*-/*/-*-replaceProduct: dumped scriptgen_promise: ', responses)
|
| 980 |
|
| 981 |
setSesh(seshid, sesh)
|
| 982 |
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)
|