Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline, set_seed | |
# Funkcja do 艂adowania modelu | |
def load_model(): | |
try: | |
model = pipeline("text-generation", model="speakleash/Bielik-7B-v0.1") | |
return model | |
except Exception as e: | |
print(f"Error loading model: {e}") | |
return None | |
model = load_model() | |
def generate_description(product_name, product_features): | |
if model is None: | |
return "Model not loaded correctly." | |
prompt = ( | |
f"Opisz produkt o nazwie {product_name}, kt贸ry posiada nast臋puj膮ce cechy: {product_features}. " | |
"Podaj jego g艂贸wne zalety, zastosowania i cechy wyr贸偶niaj膮ce. Wyja艣nij, dlaczego warto go kupi膰." | |
) | |
try: | |
result = model(prompt, max_length=200, temperature=0.7, top_p=0.9) | |
return result[0]['generated_text'] | |
except Exception as e: | |
return f"Error generating description: {e}" | |
# Konfiguracja interfejsu Gradio | |
iface = gr.Interface( | |
fn=generate_description, | |
inputs=["text", "text"], | |
outputs="text", | |
title="Bielik-7B Product Description Generator", | |
description="Wprowad藕 nazw臋 produktu i jego cechy, aby wygenerowa膰 opis." | |
) | |
if __name__ == "__main__": | |
iface.launch() | |