File size: 1,242 Bytes
ad21763
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e882144
 
ad21763
e882144
88570c9
ad21763
532fa3f
95d1712
 
 
 
 
 
 
ad21763
 
 
532fa3f
ad21763
 
 
 
 
 
 
 
 
 
 
33bfed7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""from fastai.vision.all import *
import gradio as gr

learn = load_learner('tokenizer.model')

categories = ('Rasam', 'Sambar')

def classify_image(img):
  pred, idx, probs = learn.predict(img)
  return dict(zip(categories, map(float, probs)))

image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['sambar.jpg', 'rasam.jpg']

intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch()"""

import transformers
from transformers import AutoTokenizer
import torch
import gradio as gr
from diffusers.utils.torch_utils import randn_tensor

model = "anirudh-sub/debate_model_v2.1"
tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = transformers.pipeline(
    "text-generation",
    model=model,
    torch_dtype=torch.float16,
    device_map="auto",
)

def debate_response(text):
    sequences = pipeline(
        text,
        do_sample=True,
        top_k=10,
        num_return_sequences=1,
        eos_token_id=tokenizer.eos_token_id,
        max_length=500,
    )
    response = ""
    for seq in sequences:
        reponse += {seq['generated_text']}
    return resposnse

intf = gr.Interface(fn=debate_response, inputs=gr.Textbox(), outputs="text")
intf.launch()