max-long commited on
Commit
0b6e959
·
verified ·
1 Parent(s): 32d4891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -20
app.py CHANGED
@@ -4,7 +4,14 @@ import gradio as gr
4
  from datasets import load_dataset
5
 
6
  # Load the BL dataset with streaming
7
- dataset_iter = iter(load_dataset("TheBritishLibrary/blbooks", split="train", streaming=True, trust_remote_code=True))
 
 
 
 
 
 
 
8
 
9
  # Load the model
10
  model = GLiNER.from_pretrained("max-long/textile_machines_3_oct", trust_remote_code=True)
@@ -48,25 +55,6 @@ with gr.Blocks(title="Textile Machinery NER Demo") as demo:
48
  """
49
  )
50
 
51
- gr.Code(
52
- '''
53
- from gliner import GLiNER
54
- model = GLiNER.from_pretrained("max-long/textile_machines_3_oct")
55
- text = "Your sample text here."
56
- labels = ["textile machinery"]
57
- entities = model.predict_entities(text, labels)
58
- for entity in entities:
59
- print(entity["text"], "=>", entity["label"])
60
- ''',
61
- language="python",
62
- )
63
- gr.Code(
64
- """
65
- Textile Machine 1 => textile machinery
66
- Textile Machine 2 => textile machinery
67
- """
68
- )
69
-
70
  # Display a random example
71
  input_text = gr.Textbox(
72
  value=" ",
 
4
  from datasets import load_dataset
5
 
6
  # Load the BL dataset with streaming
7
+ dataset_iter = iter(
8
+ load_dataset(
9
+ "TheBritishLibrary/blbooks",
10
+ split="train",
11
+ streaming=True,
12
+ trust_remote_code=True
13
+ ).shuffle(buffer_size=10000, seed=42) # Shuffling added here
14
+ )
15
 
16
  # Load the model
17
  model = GLiNER.from_pretrained("max-long/textile_machines_3_oct", trust_remote_code=True)
 
55
  """
56
  )
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  # Display a random example
59
  input_text = gr.Textbox(
60
  value=" ",