Spaces:
Runtime error
Runtime error
from flask import Flask, jsonify, request, render_template | |
from transformers import AutoAdapterModel, AutoTokenizer, TextClassificationPipeline | |
from huggingface_hub import Repository | |
tokenizer = AutoTokenizer.from_pretrained("UBC-NLP/MARBERT") | |
model = AutoAdapterModel.from_pretrained("UBC-NLP/MARBERT") | |
# sarcasm_adapter = Repository(local_dir="sarcasm_adapter", clone_from="nehalelkaref/sarcasm_adapter") | |
# aoc3_adapter = Repository(local_dir="aoc3_adapter", clone_from="nehalelkaref/aoc3_adapter") | |
# aoc4_adapter = Repository(local_dir="aoc4_adapter", clone_from="nehalelkaref/aoc4_adapter") | |
# fusion_adapter = Repository(local_dir="fusion_adapter", clone_from="nehalelkaref/region_fusion") | |
model.load_adapter("nehalelkaref/aoc3_adapter", set_active=True, with_head=False, source="hf") | |
model.load_adapter("nehalelkaref/aoc4_adapter", set_active=True, with_head=False, source="hf") | |
model.load_adapter("nehalelkaref/sarcasm_adapter", set_active=True, with_head=False, source="hf") | |
# model.load_adapter_fusion("nehalelkaref/region_fusion",with_head=True, set_active=True, source="hf") | |
pipe = TextClassificationPipeline(tokenizer=tokenizer, model=model) | |
app = Flask(__name__) | |
def home(): | |
return render_template('index.html') | |
if __name__ == "__main__": | |
app.run() |