pszemraj commited on
Commit
3ea8fe3
1 Parent(s): 3688939

update example loading

Browse files

Signed-off-by: peter szemraj <peterszemraj@gmail.com>

Files changed (1) hide show
  1. utils.py +3 -3
utils.py CHANGED
@@ -31,7 +31,7 @@ def truncate_word_count(text, max_words=512):
31
  return processed
32
 
33
 
34
- def load_examples(src):
35
  """
36
  load_examples - a helper function for the gradio module to load examples
37
  Returns:
@@ -39,14 +39,14 @@ def load_examples(src):
39
  """
40
  src = Path(src)
41
  src.mkdir(exist_ok=True)
42
- examples = [f for f in src.glob("*.txt")]
43
  examples = natsorted(examples)
44
  # load the examples into a list
45
  text_examples = []
46
  for example in examples:
47
  with open(example, "r") as f:
48
  text = f.read()
49
- text_examples.append([text, "large", 2, 512, 0.7, 3.5, 3])
50
 
51
  return text_examples
52
 
 
31
  return processed
32
 
33
 
34
+ def load_examples(src, filetypes=[".txt", ".pdf"]):
35
  """
36
  load_examples - a helper function for the gradio module to load examples
37
  Returns:
 
39
  """
40
  src = Path(src)
41
  src.mkdir(exist_ok=True)
42
+ examples = [f for f in src.iterdir() if f.suffix in filetypes]
43
  examples = natsorted(examples)
44
  # load the examples into a list
45
  text_examples = []
46
  for example in examples:
47
  with open(example, "r") as f:
48
  text = f.read()
49
+ text_examples.append([text, "base", 2, 1024, 0.7, 3.5, 3])
50
 
51
  return text_examples
52