waifu_gen / app.py
randeom's picture
Create app.py
19cef8f verified
raw
history blame
No virus
1.27 kB
import streamlit as st
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
# Load the Mistral model and tokenizer
model_name = "mistralai/Mistral-7B-Instruct-v0.2"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Initialize the text generation pipeline
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
# Streamlit UI
st.title("Waifu Character Generator")
# User inputs
name = st.text_input("Name of the Waifu")
hair_color = st.selectbox("Hair Color", ["Blonde", "Brunette", "Red", "Black", "Blue", "Pink"])
personality = st.selectbox("Personality", ["Tsundere", "Yandere", "Kuudere", "Dandere", "Genki", "Normal"])
outfit_style = st.selectbox("Outfit Style", ["School Uniform", "Maid Outfit", "Casual", "Kimono", "Gothic Lolita"])
# Generate button
if st.button("Generate Waifu"):
# Generate character description
prompt = f"Create a waifu character named {name} with {hair_color} hair, a {personality} personality, and wearing a {outfit_style}."
result = generator(prompt, max_length=150, num_return_sequences=1)[0]['generated_text']
# Display the generated character
st.subheader("Generated Waifu Character")
st.write(result)