niranjan2777 commited on
Commit
5f80531
·
verified ·
1 Parent(s): 29d17a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,15 +1,16 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load your model from Hugging Face
5
  pipe = pipeline(
6
  "text-generation",
7
  model="niranjan2777/cybersec-qwen",
8
  tokenizer="niranjan2777/cybersec-qwen",
9
- device_map="auto"
 
10
  )
11
 
12
- # Chat function
13
  def cybersec_assistant(user_input):
14
  messages = [
15
  {"role": "system", "content": "You are a cybersecurity expert. Give clear, structured answers."},
@@ -24,13 +25,13 @@ def cybersec_assistant(user_input):
24
 
25
  return output[0]["generated_text"][-1]["content"]
26
 
27
- # UI
28
  iface = gr.Interface(
29
  fn=cybersec_assistant,
30
  inputs=gr.Textbox(lines=3, placeholder="Ask a cybersecurity question..."),
31
  outputs="text",
32
- title="🛡️ CyberSec Assistant",
33
- description="Ask anything about cybersecurity. Powered by fine-tuned Qwen."
34
  )
35
 
36
  iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+
5
  pipe = pipeline(
6
  "text-generation",
7
  model="niranjan2777/cybersec-qwen",
8
  tokenizer="niranjan2777/cybersec-qwen",
9
+ device_map="cpu",
10
+ torch_dtype="auto",
11
  )
12
 
13
+
14
  def cybersec_assistant(user_input):
15
  messages = [
16
  {"role": "system", "content": "You are a cybersecurity expert. Give clear, structured answers."},
 
25
 
26
  return output[0]["generated_text"][-1]["content"]
27
 
28
+
29
  iface = gr.Interface(
30
  fn=cybersec_assistant,
31
  inputs=gr.Textbox(lines=3, placeholder="Ask a cybersecurity question..."),
32
  outputs="text",
33
+ title=" CyberSec Assistant_ Niranjan Labs",
34
+ description="Ask anything about cybersecurity.."
35
  )
36
 
37
  iface.launch()