Canstralian commited on
Commit
0141b73
·
verified ·
1 Parent(s): de776d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -17
app.py CHANGED
@@ -1,10 +1,6 @@
1
  import gradio as gr
2
  import torch
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
- import requests
5
- import pandas as pd
6
- import numpy as np
7
- from datasets import load_dataset
8
 
9
  # Load the model and tokenizer from Hugging Face Hub
10
  model_path = "Canstralian/pentest_ai" # Replace with your model path if needed
@@ -23,26 +19,14 @@ def generate_text(instruction):
23
  output_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
24
  return output_text
25
 
26
- # Function to load a sample dataset (this can be replaced with any dataset)
27
- def load_sample_data():
28
- # Load a sample dataset from Hugging Face Datasets
29
- dataset = load_dataset("imdb", split="train[:5]")
30
- df = pd.DataFrame(dataset)
31
- return df.head() # Show a preview of the first 5 entries
32
-
33
  # Gradio interface to interact with the text generation function
34
  iface = gr.Interface(
35
  fn=generate_text,
36
  inputs=gr.Textbox(lines=2, placeholder="Enter your question or prompt here..."),
37
  outputs="text",
38
- live=True,
39
  title="Pentest AI Text Generator",
40
  description="Generate text using a fine-tuned model for pentesting-related queries."
41
  )
42
 
43
- # Gradio interface for viewing the sample dataset (optional)
44
- data_viewer = gr.Interface(fn=load_sample_data, inputs=[], outputs="dataframe", title="Sample Dataset Viewer")
45
-
46
- # Launch the interfaces
47
  iface.launch()
48
- data_viewer.launch()
 
1
  import gradio as gr
2
  import torch
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
 
 
 
4
 
5
  # Load the model and tokenizer from Hugging Face Hub
6
  model_path = "Canstralian/pentest_ai" # Replace with your model path if needed
 
19
  output_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
20
  return output_text
21
 
 
 
 
 
 
 
 
22
  # Gradio interface to interact with the text generation function
23
  iface = gr.Interface(
24
  fn=generate_text,
25
  inputs=gr.Textbox(lines=2, placeholder="Enter your question or prompt here..."),
26
  outputs="text",
 
27
  title="Pentest AI Text Generator",
28
  description="Generate text using a fine-tuned model for pentesting-related queries."
29
  )
30
 
31
+ # Launch the interface
 
 
 
32
  iface.launch()