bareethul commited on
Commit
2458c78
·
verified ·
1 Parent(s): b8cfe69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -9,12 +9,16 @@ repo_dir = snapshot_download(repo_id=REPO_ID)
9
 
10
  # unzip the dir that holds the predictor
11
  zip_path = os.path.join(repo_dir, "autogluon_predictor_dir.zip")
12
- extract_to = "predictor_dir"
13
  if not os.path.exists(extract_to):
14
  with zipfile.ZipFile(zip_path, "r") as zf:
15
  zf.extractall(extract_to)
16
 
17
- predictor = TabularPredictor.load(extract_to, require_py_version_match=False)
 
 
 
 
18
 
19
  def predict_tabular(height, width, depth, page_count):
20
  # Validation
@@ -32,7 +36,7 @@ def predict_tabular(height, width, depth, page_count):
32
  df = pd.DataFrame([row])
33
  pred = int(predictor.predict(df)[0])
34
 
35
- return {"Predicted Genre": pred}
36
 
37
  with gr.Blocks(title="Book Genre Predictor") as demo:
38
  gr.Markdown("## Predict the Genre of a Book (Numeric Labels)")
@@ -63,4 +67,4 @@ with gr.Blocks(title="Book Genre Predictor") as demo:
63
  outputs=out
64
  )
65
 
66
-
 
9
 
10
  # unzip the dir that holds the predictor
11
  zip_path = os.path.join(repo_dir, "autogluon_predictor_dir.zip")
12
+ extract_to = "/tmp/predictor_dir"
13
  if not os.path.exists(extract_to):
14
  with zipfile.ZipFile(zip_path, "r") as zf:
15
  zf.extractall(extract_to)
16
 
17
+ predictor = TabularPredictor.load(
18
+ extract_to,
19
+ require_py_version_match=False,
20
+ reset_paths=True
21
+ )
22
 
23
  def predict_tabular(height, width, depth, page_count):
24
  # Validation
 
36
  df = pd.DataFrame([row])
37
  pred = int(predictor.predict(df)[0])
38
 
39
+ return f"Predicted Genre Code: {int(pred)}"
40
 
41
  with gr.Blocks(title="Book Genre Predictor") as demo:
42
  gr.Markdown("## Predict the Genre of a Book (Numeric Labels)")
 
67
  outputs=out
68
  )
69
 
70
+ demo.launch(share=True)