| import gradio as gr | |
| from transformers import pipeline | |
| import torch | |
| import os | |
| token = os.environ.get('HF_TOKEN') | |
| print('🔄 Loading Gemma 31B...') | |
| pipe = pipeline( | |
| 'text-generation', | |
| model='Arabic250/gemma4', | |
| torch_dtype=torch.bfloat16, | |
| device_map='auto', | |
| token=token | |
| ) | |
| def predict(text): | |
| if not text: return "يرجى إدخال نص" | |
| res = pipe(text, max_new_tokens=256, do_sample=True, temperature=0.7) | |
| return res[0]['generated_text'] | |
| demo = gr.Interface(fn=predict, inputs="text", outputs="text", title="Gemma 4 31B Studio") | |
| demo.launch() | |