Spaces:
Build error
Build error
Avaya Aggarwal commited on
Commit ·
33f60f8
1
Parent(s): 7179ddd
changes
Browse filesFiles changed (2)
- app.py+29-25
- requirements.txt+1
123433 unmodified lines3839404142434445464748491 unmodified line515253545556576 unmodified lines6465666768697071727374757677787980811 unmodified line838485868788899091929394import osimport numpy as npimport pandas as pdfrom statsmodels.tsa.arima.model import ARIMA33 unmodified linesreturn plot_base64def get_product_name(url):# Extract the product name from the URLmatch = re.search(r'/([^/]+)\.csv', url)if match:return match.group(1)else:return Nonedef predict(url):# Get the product name from the URL1 unmodified lineif product_name is not None:# Adjust the path based on the provided productcsv_path = f"datasets/{product_name}.csv"try:dataset = pd.read_csv(csv_path)6 unmodified lines# HTML template for rendering the plothtml_template = f"""<!DOCTYPE html><html><head><title>ARIMA Time Series Forecasting</title></head><body><h1>ARIMA Time Series Forecasting</h1><div><img src="data:image/png;base64,{plot_base64}" alt="ARIMA Forecast Plot"></div></body></html>"""return html_templateexcept FileNotFoundError:1 unmodified lineelse:return "No data found for the given URL."# Create a Gradio Interfaceiface = gr.Interface(fn=predict,inputs=gr.Textbox(prompt="Enter product URL", default=""),outputs="html",)# Launch the Gradio Interfaceiface.launch()12333 unmodified lines37383940414243444546474849505152535455565758591 unmodified line616263646566676 unmodified lines7475767778798081828384858687888990911 unmodified line939495969798import numpy as npimport pandas as pdfrom statsmodels.tsa.arima.model import ARIMA33 unmodified linesreturn plot_base64def get_product_name(url):# Map webpage URLs to CSV file namesurl_mapping = {'https://www.flipkart.com/lg-ur7500-108-cm-43-inch-ultra-hd-4k-led-smart-webos-tv-2023-a5-ai-processor-4k-gen6-60hz-refresh-rate-magic-remote-capability/p/itm926f6b65c136b?pid=TVSGQQDYSCFGRX2F&lid=LSTTVSGQQDYSCFGRX2FVATNAW&fm=neo%2Fmerchandising&iid=M_f14f9138-3f49-4442-9825-2e80b67ca013_27.GO45SKVBQD2H&ppt=hp&ppn=homepage&ssid=ucylcxqj1c0000001706348119148&otracker=clp_omu_Televisions_3_27.dealCard.OMU_tvs-and-appliances-new-clp-store_tvs-and-appliances-new-clp-store_GO45SKVBQD2H_25&otracker1=clp_omu_PINNED_neo%2Fmerchandising_Televisions_NA_dealCard_cc_3_NA_view-all_25&cid=GO45SKVBQD2H': 'lgMonitor.csv','https://www.flipkart.com/apple-ipad-10th-gen-64-gb-rom-10-9-inch-wi-fi-only-pink/p/itmaf20456d05879?pid=TABGJ6XUSFTPNTKH&lid=LSTTABGJ6XUSFTPNTKHITLWPF&marketplace=FLIPKART&q=%2Fapple-ipad-10th-gen-64-gb-rom&store=tyy%2Fhry&srno=s_1_3&otracker=search&otracker1=search&fm=Search&iid=d0c72954-0a17-40fc-b627-0a02420a730a.TABGJ6XUSFTPNTKH.SEARCH&ppt=pp&ppn=pp&ssid=95nrm0ypv40000001706348742165&qH=3e0ceaa4a1aebf32': 'IPad.csv','https://www.flipkart.com/hf-mrf-grand-vk-18-full-size-ideal-15-21-years-complete-cricket-kit/p/itmae4fff077ce32?pid=KITG86QHGZZKTKRG&lid=LSTKITG86QHGZZKTKRGVELUCO&marketplace=FLIPKART&q=cricket+kit&store=abc%2F5lf%2Fra8&spotlightTagId=BestsellerId_abc%2F5lf%2Fra8&srno=s_1_1&otracker=search&otracker1=search&fm=Search&iid=66f4bc54-2518-4fe6-87d8-77285a37918b.KITG86QHGZZKTKRG.SEARCH&ppt=sp&ppn=sp&ssid=jrcatake680000001706349413005&qH=602f2733d0cdfdfb': 'cricketball.csv','https://www.flipkart.com/oppo-enco-buds-2-28-hours-battery-life-deep-noise-cancellation-bluetooth-headset/p/itm3344fa26518ed?pid=ACCGH7YZY6AHGCHJ&lid=LSTACCGH7YZY6AHGCHJHLWF41&marketplace=FLIPKART&q=earbuds&store=0pm%2Ffcn%2F821%2Fa7x%2F2si&srno=s_1_4&otracker=AS_Query_PredictiveAutoSuggest_10_0_na_na_na&otracker1=AS_Query_PredictiveAutoSuggest_10_0_na_na_na&fm=search-autosuggest&iid=542a4755-f4d6-4aec-b0bd-879c71423622.ACCGH7YZY6AHGCHJ.SEARCH&ppt=sp&ppn=sp&ssid=1kux6gdhv40000001706350125817&qH=2951f68ff1fee1e0': 'earphones.csv',# Add more mappings as needed}# Extract the product name from the URLmatch = re.search(r'/([^/]+)\.csv', url)if match:product_name = match.group(1)# Check if the product name is in the mappingif product_name in url_mapping:return url_mapping[product_name]return Nonedef predict(url):# Get the product name from the URL1 unmodified lineif product_name is not None:# Adjust the path based on the provided productcsv_path = f"datasets/{product_name}"try:dataset = pd.read_csv(csv_path)6 unmodified lines# HTML template for rendering the plothtml_template = f"""<!DOCTYPE html><html><head><title>ARIMA Time Series Forecasting</title></head><body><h1>ARIMA Time Series Forecasting</h1><div><img src="data:image/png;base64,{plot_base64}" alt="ARIMA Forecast Plot"></div></body></html>"""return html_templateexcept FileNotFoundError:1 unmodified lineelse:return "No data found for the given URL."# Gradio Interfaceiface = gr.Interface(fn=predict, inputs="text", outputs="html", live=True)iface.launch()
123numpy==1.21.2pandas==1.3.3statsmodels==0.12.21234--upgrade pipnumpy==1.21.2pandas==1.3.3statsmodels==0.12.2
app.py+29-25
requirements.txt+1