Download app.py from wmateam/tagging: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/wmateam/tagging/resolve/main/app.py
- Command line
-
hf download hf://spaces/wmateam/tagging/app.py
-
curl -L -o app.py https://huggingface.co/spaces/wmateam/tagging/resolve/main/app.py
1.1 kB
| import os | |
| from Tagger import Tagger | |
| import pandas as pd | |
| import spaces | |
| from pathlib import Path | |
| import gradio as gr | |
| model = "openai/gpt-oss-120b" | |
| tagger = Tagger(model_name=model) | |
| folder_path = "passages/" | |
| files = [ | |
| f for f in os.listdir(folder_path) | |
| if os.path.isfile(os.path.join(folder_path, f)) | |
| ] | |
| OUT_DIR = Path("outputs") | |
| OUT_DIR.mkdir(exist_ok=True) | |
| def produce_result(): | |
| result = {} | |
| j = 1 | |
| for file in files: | |
| print(j) | |
| j += 1 | |
| path = "passages/" + file | |
| with open(path, "r", encoding="utf-8") as f: | |
| text = f.read() | |
| assigned_tag = tagger.tag(text) | |
| result[file] = assigned_tag | |
| return result | |
| def make_csv(): | |
| result = produce_result() | |
| df = pd.DataFrame( | |
| [(k, v) for k, v in result.items()], | |
| columns=["file_name", "tags"] | |
| ) | |
| out_path = OUT_DIR / "Llama_3_1_8B_Instruct_75_100.csv" | |
| df.to_csv(out_path, index=False) # write to disk | |
| return str(out_path) | |
| demo = gr.Interface(fn=make_csv, inputs=None, outputs=gr.File(label="Download CSV")) | |
| demo.launch() | |