Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import torch
|
2 |
from peft import PeftModel, PeftConfig
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
4 |
|
5 |
peft_model_id = f"alimrb/eff24"
|
6 |
config = PeftConfig.from_pretrained(peft_model_id)
|
@@ -14,7 +18,6 @@ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
|
14 |
# Load the Lora model
|
15 |
model = PeftModel.from_pretrained(model, peft_model_id)
|
16 |
|
17 |
-
|
18 |
def make_inference(product_name, product_description):
|
19 |
batch = tokenizer(
|
20 |
f"### Product and Description:\n{product_name}: {product_description}\n\n### Ad:",
|
@@ -26,18 +29,15 @@ def make_inference(product_name, product_description):
|
|
26 |
|
27 |
return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|
28 |
|
29 |
-
|
30 |
if __name__ == "__main__":
|
31 |
-
#
|
32 |
-
|
33 |
-
|
34 |
-
gr.Interface(
|
35 |
make_inference,
|
36 |
[
|
37 |
-
|
38 |
-
|
39 |
],
|
40 |
-
|
41 |
title="EFF24",
|
42 |
-
description="EFF24 is a generative model that generates ads for products."
|
43 |
-
).launch()
|
|
|
1 |
import torch
|
2 |
from peft import PeftModel, PeftConfig
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
# Import the specific Gradio components
|
7 |
+
from gradio import Textbox, Interface
|
8 |
|
9 |
peft_model_id = f"alimrb/eff24"
|
10 |
config = PeftConfig.from_pretrained(peft_model_id)
|
|
|
18 |
# Load the Lora model
|
19 |
model = PeftModel.from_pretrained(model, peft_model_id)
|
20 |
|
|
|
21 |
def make_inference(product_name, product_description):
|
22 |
batch = tokenizer(
|
23 |
f"### Product and Description:\n{product_name}: {product_description}\n\n### Ad:",
|
|
|
29 |
|
30 |
return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|
31 |
|
|
|
32 |
if __name__ == "__main__":
|
33 |
+
# Create a Gradio interface
|
34 |
+
Interface(
|
|
|
|
|
35 |
make_inference,
|
36 |
[
|
37 |
+
Textbox(lines=2, label="Product Name"),
|
38 |
+
Textbox(lines=5, label="Product Description"),
|
39 |
],
|
40 |
+
Textbox(label="Ad"),
|
41 |
title="EFF24",
|
42 |
+
description="EFF24 is a generative model that generates ads for products."
|
43 |
+
).launch()
|