NoaiGPT commited on
Commit
84ccd93
1 Parent(s): 122c44e
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -2,7 +2,7 @@ import json
2
  import torch
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
  from peft import PeftModel, PeftConfig
5
- from huggingface_hub import HfApi, Repository
6
  import gradio as gr
7
 
8
  # Global variables to store the model and tokenizer
@@ -74,21 +74,20 @@ def run_merge_and_push():
74
 
75
  # Gradio interface
76
  with gr.Blocks() as demo:
77
- with gr.TabbedInterface(["Generate Text", "Merge and Push"]) as tabs:
78
- with tabs[0]:
79
- iface = gr.Interface(
80
- fn=generate_text,
81
- inputs=gr.Textbox(lines=5, label="Input Text"),
82
- outputs=gr.Textbox(lines=10, label="Generated Text"),
83
- title="Merged Llama 3 8B Instruct Model",
84
- description="Enter text to generate a response from the merged model.",
85
- )
86
- iface.launch()
87
-
88
- with tabs[1]:
89
- merge_and_push_button = gr.Button("Merge Models and Push to Hub")
90
- merge_and_push_output = gr.Textbox(lines=20, label="Merge and Push Output")
91
- merge_and_push_button.click(run_merge_and_push, outputs=merge_and_push_output)
92
 
93
  # Launch the interface
94
  if __name__ == "__main__":
 
2
  import torch
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
  from peft import PeftModel, PeftConfig
5
+ from huggingface_hub import HfApi
6
  import gradio as gr
7
 
8
  # Global variables to store the model and tokenizer
 
74
 
75
  # Gradio interface
76
  with gr.Blocks() as demo:
77
+ with gr.Tab("Generate Text"):
78
+ iface = gr.Interface(
79
+ fn=generate_text,
80
+ inputs=gr.Textbox(lines=5, label="Input Text"),
81
+ outputs=gr.Textbox(lines=10, label="Generated Text"),
82
+ title="Merged Llama 3 8B Instruct Model",
83
+ description="Enter text to generate a response from the merged model.",
84
+ )
85
+ iface.launch()
86
+
87
+ with gr.Tab("Merge and Push"):
88
+ merge_and_push_button = gr.Button("Merge Models and Push to Hub")
89
+ merge_and_push_output = gr.Textbox(lines=20, label="Merge and Push Output")
90
+ merge_and_push_button.click(run_merge_and_push, outputs=merge_and_push_output)
 
91
 
92
  # Launch the interface
93
  if __name__ == "__main__":