Malek-AI commited on
Commit
dd46dba
·
verified ·
1 Parent(s): 08bfeb4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -40
app.py CHANGED
@@ -6,44 +6,10 @@ def mask(text):
6
  output = mask_model(text)
7
  return output[0]['sequence']
8
 
9
- with gr.Blocks() as demo:
 
10
  gr.Markdown("BERT Test - Zircon.tech")
11
- #tab single model
12
- with gr.Tab("Single-Models"):
13
- with gr.Row(equal_height=True):
14
- with gr.Column(scale=1):
15
- textbox_mask = gr.Textbox(label="Give me a sentance and use the word [MASK] to predict what will go there")
16
- mask_button = gr.Button("Predict")
17
- textbox_mask_output = gr.Textbox()
18
-
19
- mask_button.click(fn=mask,
20
- inputs = textbox_mask,
21
- outputs = textbox_mask_output)
22
- demo.launch(debug=True)
23
-
24
-
25
- # # Load the model and tokenizer
26
- # tokenizer = BertTokenizer.from_pretrained("google-bert/bert-base-uncased")
27
- # model = BertModel.from_pretrained("google-bert/bert-base-uncased")
28
-
29
- # def predict(input_text):
30
- # # Preprocess the input text
31
- # inputs = tokenizer(input_text, return_tensors="pt")
32
- # # Get the model's output
33
- # outputs = model(**inputs)
34
- # # Extract the last hidden state
35
- # last_hidden_state = outputs.last_hidden_state[:, 0, :]
36
- # # Return a response based on the output
37
- # return {"response": last_hidden_state.detach().numpy().tolist()}
38
-
39
- # # Create a Gradio interface
40
- # iface = gr.Interface(
41
- # fn=predict,
42
- # inputs="text",
43
- # outputs="text",
44
- # title="BERT-based Text Analyzer",
45
- # description="Enter some text to analyze with BERT!"
46
- # )
47
-
48
- # # Launch the interface
49
- # iface.launch()
 
6
  output = mask_model(text)
7
  return output[0]['sequence']
8
 
9
+ # Gradio UI
10
+ with gr.Blocks() as ui:
11
  gr.Markdown("BERT Test - Zircon.tech")
12
+ gr.Button("Predict").click(fn=mask,
13
+ inputs = gr.Textbox(label="Give me a sentance and use the word [MASK] to predict what will go there"),
14
+ outputs = gr.Textbox())
15
+ ui.launch(share=True)