Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,55 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
import matplotlib.pyplot as plt
|
| 5 |
-
import datetime
|
| 6 |
-
from datetime import timedelta
|
| 7 |
-
import time
|
| 8 |
-
import copy
|
| 9 |
-
import openpyxl as xl
|
| 10 |
-
import json
|
| 11 |
-
import gradio as gr
|
| 12 |
-
import io
|
| 13 |
-
from PIL import Image
|
| 14 |
|
| 15 |
-
|
| 16 |
-
import GA
|
| 17 |
-
import OR_tools as ort
|
| 18 |
-
import MIP
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
return np.asarray(img)
|
| 26 |
-
|
| 27 |
-
def JSSP(method,temp_file):
|
| 28 |
-
xls = pd.ExcelFile(temp_file.name)
|
| 29 |
-
print(xls)
|
| 30 |
-
print("Input File is :",xls)
|
| 31 |
-
if method == "Genetic Algo":
|
| 32 |
-
op, fig, df = GA.input_file(xls)
|
| 33 |
-
|
| 34 |
-
elif method == "Python OR":
|
| 35 |
-
op, fig, df = ort.or_fn(xls)
|
| 36 |
-
|
| 37 |
-
else:
|
| 38 |
-
op, fig, df = MIP.MIP_fn(xls)
|
| 39 |
-
|
| 40 |
-
img = plotly_fig2array(fig)
|
| 41 |
-
# data = pd.DataFrame(df)
|
| 42 |
-
df.to_excel("op_data.xlsx",index=False)
|
| 43 |
-
data_op = ["op_data.xlsx"]
|
| 44 |
-
return op, img,data_op
|
| 45 |
-
|
| 46 |
-
demo = gr.Interface(JSSP,
|
| 47 |
-
inputs=[gr.Radio(["Genetic Algo", "Python OR", "MIP solution"], label="Solution Method", info="Choose one method to solve ypur Job Shop problem."),gr.File(label = 'Input File')],
|
| 48 |
-
examples =[["Python OR","Demo_data.xlsx"]],
|
| 49 |
-
outputs = ["text","image",gr.File(label='Output File')],
|
| 50 |
-
title = "Job Shop Scheduling Problem",
|
| 51 |
-
description = "Upload an excel file containing Machine Sequnce and Processing Time for a n x m problem to optimize makespan for manufacturing or Job schedule. Choose the method you want the problem to be solved before clicking Submit! \n For Demo purpose, use the example data provided BELOW.",
|
| 52 |
-
cache_examples = False )
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
demo.queue().launch(debug=True,show_error=True)
|
|
|
|
| 1 |
+
from huggingface_hub import Repository
|
| 2 |
+
import os
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
token=os.environ["HUGGING_FACE_HUB_TOKEN"]
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Download from a dataset
|
| 8 |
+
hf_hub_download(repo_id="Brillio-DS/Optimization_JSSP",local_dir=os.getcwd(), filename="main.py", repo_type="dataset")
|
| 9 |
+
print(os.listdir())
|
| 10 |
+
from main import run
|
| 11 |
+
run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|