ubiodee commited on
Commit
a3baa6a
·
verified ·
1 Parent(s): 70bb8a0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer
4
+
5
+ # Load the model and tokenizer
6
+ MODEL_NAME = "ubiodee/Cardano_plutus" # Your fine-tuned model
7
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
8
+ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
9
+
10
+ # Function to generate response from the model
11
+ def generate_response(prompt):
12
+ inputs = tokenizer(prompt, return_tensors="pt")
13
+ with torch.no_grad():
14
+ output = model.generate(**inputs, max_length=512)
15
+ response = tokenizer.decode(output[0], skip_special_tokens=True)
16
+ return response
17
+
18
+ # Gradio Interface
19
+ iface = gr.Interface(
20
+ fn=generate_response,
21
+ inputs=gr.Textbox(label="Enter your prompt"),
22
+ outputs=gr.Textbox(label="Model Response"),
23
+ title="Cardano Plutus AI",
24
+ description="Type in your question or prompt related to Cardano Plutus and get a response from the AI model.",
25
+ theme="default"
26
+ )
27
+
28
+ # Launch app
29
+ iface.launch()