My space is stuck on building forever
import gradio as gr
from transformers import pipeline import os
# Grab the token from the Space’s Secrets token = os.environ.get(“HF_TOKEN”)
# Load the model directly into the Space’s generous 16GB RAM print(“Loading model into memory…”) ner_pipe = pipeline( “ner”, model=“AHaldar/MythologicalNER”, token=token, aggregation_strategy=“none” ) print(“Model loaded successfully!”)
def analyze_text(text): # The pipeline handles tokenization and PyTorch math results = ner_pipe(text) # Clean up numpy types for safe JSON transmission cleaned = [] for r in results: cleaned.append({ “entity”: str(r.get(“entity_group”, r.get(“entity”, “O”))), “word”: str(r[“word”]), “start”: int(r[“start”]), “end”: int(r[“end”]) }) return cleaned
# Gradio automatically turns this interface into a REST API demo = gr.Interface(fn=analyze_text, inputs=“text”, outputs=“json”) demo.launch()
my app.py is stuck on building forever. I do not understand why. My requirements.txt looks something like this:
transformers
torch
Discussion in the ATmosphere