Spaces:
Sleeping
Sleeping
Update app.py
Browse files5 unmodified lines6789101112131415161718192021222324252627282930313233343539 unmodified lines757677787980818283118 unmodified lines2022032042055 unmodified linesimport jsonimport gradio as grimport torchfrom unsloth import FastModelimport spaces# ββ Model loading βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββMODEL_ID = "lsadouk1111/VisualStep"model = Nonetokenizer = Nonedef load_model():global model, tokenizerif model is None:print("Loading VisualStep model...")model, tokenizer = FastModel.from_pretrained(model_name=MODEL_ID,max_seq_length=512,load_in_4bit=True,dtype=None,)FastModel.for_inference(model)model.eval()print("Model ready.")# ββ System prompt βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSYSTEM_PROMPT = """You are an expert in ADHD classroom accommodations for primary school children aged 5-10.Transform the teacher's spoken classroom instruction into an ADHD-adapted visual step card.39 unmodified lines# ββ Generation ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ@spaces.GPUdef generate_step_card(instruction, year, subject):if not instruction.strip():return "Please enter a classroom instruction."messages = [{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": f"Year: {year} | Subject: {subject} | Instruction: {instruction}"},118 unmodified linesAll inference runs locally β no data is sent to external servers.""")demo.launch()5 unmodified lines67891011121314151617181939 unmodified lines596061626364656667686970717273747576777879808182118 unmodified lines2012022032045 unmodified linesimport jsonimport gradio as grimport torchimport spaces# ββ Model loading βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββMODEL_ID = "lsadouk1111/VisualStep"model = Nonetokenizer = None# ββ System prompt βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSYSTEM_PROMPT = """You are an expert in ADHD classroom accommodations for primary school children aged 5-10.Transform the teacher's spoken classroom instruction into an ADHD-adapted visual step card.39 unmodified lines# ββ Generation ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ@spaces.GPUdef generate_step_card(instruction, year, subject):global model, tokenizerif not instruction.strip():return "Please enter a classroom instruction."# Load model on first call (inside GPU context)if model is None:from unsloth import FastModelglobal model, tokenizermodel, tokenizer = FastModel.from_pretrained(model_name=MODEL_ID,max_seq_length=512,load_in_4bit=True,dtype=None,)FastModel.for_inference(model)model.eval()messages = [{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": f"Year: {year} | Subject: {subject} | Instruction: {instruction}"},118 unmodified linesAll inference runs locally β no data is sent to external servers.""")demo.launch()
app.py+16-17