ziem-io commited on
Commit
9cfe75e
·
1 Parent(s): 577c02d

New: Add deps

Browse files
Files changed (2) hide show
  1. app.py +10 -4
  2. requirements.txt +3 -1
app.py CHANGED
@@ -4,6 +4,8 @@ import html
4
  import numpy as np
5
  import types
6
  from huggingface_hub import hf_hub_download
 
 
7
 
8
  # Projektspezifische Module
9
  from lib.bert_regressor import BertMultiHeadRegressor
@@ -15,7 +17,9 @@ from lib.bert_regressor_utils import (
15
  ICONS
16
  )
17
 
18
- ######################################
 
 
19
 
20
  # offizielles Mirror-Repo mit lid.176.*
21
  lid_path = hf_hub_download(
@@ -46,11 +50,13 @@ def _predict_np2_compat(self, text, k=1, threshold=0.0, on_unicode_error='strict
46
  # Instanz patchen
47
  lid_model.predict = types.MethodType(_predict_np2_compat, lid_model)
48
 
49
- ### Check if lang is english ##############################################
50
 
51
  def is_eng(review: str):
52
  lang_labels, lang_probs = lid_model.predict(review)
53
 
 
 
54
  if not lang_labels: # kein Label zurückgegeben
55
  return False, 0.0
56
 
@@ -59,7 +65,7 @@ def is_eng(review: str):
59
 
60
  return lang_label[1] == "__label__en", lang_prob
61
 
62
- ### Do actual prediction ##############################################
63
 
64
  def predict(review: str, mode: str):
65
 
@@ -87,7 +93,7 @@ def predict(review: str, mode: str):
87
  }
88
  return html_out, json_out
89
 
90
- ### Create Form interface with Gradio Framework ########################
91
 
92
  iface = gr.Interface(
93
  fn=predict,
 
4
  import numpy as np
5
  import types
6
  from huggingface_hub import hf_hub_download
7
+ from safetensors.torch import load_file
8
+ from transformers import AutoTokenizer
9
 
10
  # Projektspezifische Module
11
  from lib.bert_regressor import BertMultiHeadRegressor
 
17
  ICONS
18
  )
19
 
20
+ ### Stettings ####################################################################
21
+
22
+ ##################################################################################
23
 
24
  # offizielles Mirror-Repo mit lid.176.*
25
  lid_path = hf_hub_download(
 
50
  # Instanz patchen
51
  lid_model.predict = types.MethodType(_predict_np2_compat, lid_model)
52
 
53
+ ### Check if lang is english #####################################################
54
 
55
  def is_eng(review: str):
56
  lang_labels, lang_probs = lid_model.predict(review)
57
 
58
+ print(lang_labels, lang_probs)
59
+
60
  if not lang_labels: # kein Label zurückgegeben
61
  return False, 0.0
62
 
 
65
 
66
  return lang_label[1] == "__label__en", lang_prob
67
 
68
+ ### Do actual prediction #########################################################
69
 
70
  def predict(review: str, mode: str):
71
 
 
93
  }
94
  return html_out, json_out
95
 
96
+ ### Create Form interface with Gradio Framework ##################################
97
 
98
  iface = gr.Interface(
99
  fn=predict,
requirements.txt CHANGED
@@ -1,4 +1,6 @@
1
  torch>=2.2,<3.0
2
  transformers==4.51.0
3
  numpy
4
- fasttext
 
 
 
1
  torch>=2.2,<3.0
2
  transformers==4.51.0
3
  numpy
4
+ fasttext
5
+ huggingface_hub
6
+ safetensors