Download app.py from hariom329/abc: direct link, hf CLI and curl.
- Browser
- Download file 727 Bytes
-
https://huggingface.co/spaces/hariom329/abc/resolve/main/app.py
- Command line
-
hf download hf://spaces/hariom329/abc/app.py
-
curl -L -o app.py https://huggingface.co/spaces/hariom329/abc/resolve/main/app.py
727 Bytes
| import gradio as gr | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| from peft import PeftModel | |
| # Load the model and tokenizer from Hugging Face Model Hub | |
| tokenizer = AutoTokenizer.from_pretrained("hariom329/Fashionista") | |
| model = AutoModelForCausalLM.from_pretrained("hariom329/Fashionista") | |
| model = PeftModel.from_pretrained(model, "hariom329/Fashionista") | |
| def answer(query): | |
| inputs = tokenizer(query, return_tensors="pt") | |
| outputs = model.generate(**inputs, max_new_tokens=200) | |
| response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| return response | |
| # Define the Gradio interface | |
| iface = gr.Interface(fn=answer, inputs="text", outputs="text", title="Fashion Assistant") | |
| iface.launch() | |