richylyq commited on
Commit
e939d89
·
1 Parent(s): 7239594

add logging and test

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -24,9 +24,13 @@ from gradio.themes.utils import colors, fonts, sizes
24
  import argparse
25
 
26
  import langid
27
- from transformers import pipeline, AutoModelForSeq2SeqLM, AutoTokenizer
28
  from easynmt import EasyNMT
29
 
 
 
 
 
30
  # # Initialize nllb-200 models
31
  # tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
32
  # model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")
@@ -34,9 +38,11 @@ from easynmt import EasyNMT
34
  # Initialize mbart50 models
35
  mbart_m2en_model = EasyNMT("mbart50_m2en")
36
  mbart_en2m_model = EasyNMT("mbart50_en2m")
 
37
 
38
  # Initialize m2m_100 models
39
  m2m_model = EasyNMT("m2m_100_1.2B")
 
40
 
41
 
42
  class myTheme(Base):
@@ -102,6 +108,7 @@ def detect_lang(article):
102
  """
103
 
104
  result_lang = langid.classify(article)
 
105
  return result_lang[0]
106
 
107
 
 
24
  import argparse
25
 
26
  import langid
27
+ from transformers import pipeline, AutoModelForSeq2SeqLM, AutoTokenizer, logging
28
  from easynmt import EasyNMT
29
 
30
+ # Initialize logging
31
+ logging.set_verbosity_info()
32
+ logger = logging.get_logger("transformers")
33
+
34
  # # Initialize nllb-200 models
35
  # tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
36
  # model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")
 
38
  # Initialize mbart50 models
39
  mbart_m2en_model = EasyNMT("mbart50_m2en")
40
  mbart_en2m_model = EasyNMT("mbart50_en2m")
41
+ logger.info("mbart50 models initialized")
42
 
43
  # Initialize m2m_100 models
44
  m2m_model = EasyNMT("m2m_100_1.2B")
45
+ logger.info("m2m_100 models initialized")
46
 
47
 
48
  class myTheme(Base):
 
108
  """
109
 
110
  result_lang = langid.classify(article)
111
+ logger.info(f"language detected as {result_lang}")
112
  return result_lang[0]
113
 
114