teragron commited on
Commit
891d7a5
·
1 Parent(s): f2812b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -8
app.py CHANGED
@@ -6,12 +6,7 @@ tokenizer = LlamaTokenizer.from_pretrained("llama_tokenizer")
6
 
7
  def tokenize(input_text, file=None):
8
  if file:
9
- print(type(file))
10
- print(len(file))
11
- # Use the file's content directly
12
  full_text = file.read().decode("utf-8")
13
- print(type(full_text))
14
- print(len(full_text))
15
  else:
16
  full_text = input_text
17
 
@@ -26,12 +21,11 @@ with gr.Blocks() as demo:
26
  """)
27
  with gr.Row():
28
  text_input = gr.Textbox(placeholder="Enter prompt")
29
- file_input = gr.File(label="Upload File", type="file")
30
  with gr.Column():
31
  out = gr.Textbox(label="Number of tokens")
32
  run_btn = gr.Button("Run")
33
  run_btn.click(fn=tokenize, inputs=[text_input, file_input], outputs=out)
34
 
35
- # Set share=True to create a public link
36
- demo.launch(share=True)
37
 
 
6
 
7
  def tokenize(input_text, file=None):
8
  if file:
 
 
 
9
  full_text = file.read().decode("utf-8")
 
 
10
  else:
11
  full_text = input_text
12
 
 
21
  """)
22
  with gr.Row():
23
  text_input = gr.Textbox(placeholder="Enter prompt")
24
+ file_input = gr.File(label="Upload File", type="byte") # Change type to "byte"
25
  with gr.Column():
26
  out = gr.Textbox(label="Number of tokens")
27
  run_btn = gr.Button("Run")
28
  run_btn.click(fn=tokenize, inputs=[text_input, file_input], outputs=out)
29
 
30
+ demo.launch()
 
31