File size: 794 Bytes
11f8d70
decedce
 
 
 
 
 
af71772
 
 
11f8d70
 
 
 
decedce
 
af71772
 
 
 
 
 
 
 
 
decedce
 
 
 
 
af71772
 
 
 
 
 
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
import gradio as gr
import spaces
import subprocess
# from transformers import AutoTokenizer, AutoModelForCausalLM

result = subprocess.run(["python3", "-m", "pip", "install", "transformers==4.34.0"], shell=True, capture_output=True, text=True)
print(result.stdout)

model = None


def greet(name):
    return "Hello " + name + "!!"

@spaces.GPU
def load_model():
    print(f"Loading model...")
    model_path = "meta-llama/Meta-Llama-3-8B"
    tokenizer = AutoTokenizer.from_pretrained(model_path)
    model = AutoModelForCausalLM.from_pretrained(
        model_path,
        torch_dtype=torch.bfloat16,
        device_map="auto",
    )


def main():

    load_model()

    demo = gr.Interface(fn=greet, inputs="text", outputs="text")
    demo.launch()


if __name__ == "__main__":
    main()