mdsr commited on
Commit
3bde99c
·
1 Parent(s): 78bb9d8

catch dataset saver exception

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +17 -9
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🏆
4
  colorFrom: green
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 4.25.0
8
  app_file: app.py
9
  pinned: false
10
  license: cc-by-4.0
 
4
  colorFrom: green
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 4.29.0
8
  app_file: app.py
9
  pinned: false
10
  license: cc-by-4.0
app.py CHANGED
@@ -38,15 +38,19 @@ CUSTOM_CSS = """
38
  }
39
  """
40
 
41
- HF_TOKEN = os.getenv("HF_TOKEN")
42
- request_logger = (
43
- gradio.HuggingFaceDatasetSaver(
44
- HF_TOKEN,
45
- "sltAI/crowdsourced-text-to-sign-language-rule-based-translation-corpus",
 
 
 
 
46
  )
47
- if HF_TOKEN
48
- else gradio.CSVLogger()
49
- )
50
 
51
  translation_model = slt.models.ConcatenativeSynthesis("ur", "pk-sl", "video")
52
  language_models: Dict[str, slt.models.BeamSampling] = {}
@@ -127,7 +131,11 @@ def translate(text: str, text_lang: str, sign_lang: str, sign_format: str):
127
 
128
  with gradio.Blocks(title=TITLE, head=CUSTOM_JS, css=CUSTOM_CSS) as gradio_app:
129
  gradio.Markdown(f"# {TITLE}")
130
- gradio.Markdown(DESCRIPTION)
 
 
 
 
131
  with gradio.Row(): # Inputs and Outputs
132
  with gradio.Column(): # Inputs
133
  gradio.Markdown("## Input Text")
 
38
  }
39
  """
40
 
41
+ try:
42
+ HF_TOKEN = os.getenv("HF_TOKEN")
43
+ request_logger = (
44
+ gradio.HuggingFaceDatasetSaver(
45
+ HF_TOKEN,
46
+ "sltAI/crowdsourced-text-to-sign-language-rule-based-translation-corpus",
47
+ )
48
+ if HF_TOKEN
49
+ else gradio.CSVLogger()
50
  )
51
+ except Exception as e:
52
+ request_logger = gradio.CSVLogger()
53
+ print(f"Error in setting up HuggingFaceDatasetSaver: {e}")
54
 
55
  translation_model = slt.models.ConcatenativeSynthesis("ur", "pk-sl", "video")
56
  language_models: Dict[str, slt.models.BeamSampling] = {}
 
131
 
132
  with gradio.Blocks(title=TITLE, head=CUSTOM_JS, css=CUSTOM_CSS) as gradio_app:
133
  gradio.Markdown(f"# {TITLE}")
134
+ gradio.Markdown(
135
+ DESCRIPTION + f"\n\n<sub>Error in setting up HuggingFaceDatasetSaver: {e}<sub/>"
136
+ if not isinstance(request_logger, gradio.HuggingFaceDatasetSaver)
137
+ else ""
138
+ )
139
  with gradio.Row(): # Inputs and Outputs
140
  with gradio.Column(): # Inputs
141
  gradio.Markdown("## Input Text")