nehalelkaref commited on
Commit
c6d903d
1 Parent(s): 5178cd4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -1,4 +1,24 @@
1
  from flask import Flask, jsonify, request
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  app = Flask(__name__)
4
 
 
1
  from flask import Flask, jsonify, request
2
+ from transformers import AutoAdapterModel, AutoTokenizer, TextClassificationPipeline
3
+ from huggingface_hub import Repository
4
+
5
+ tokenizer = AutoTokenizer.from_pretrained("UBC-NLP/MARBERT")
6
+
7
+ sarcasm_adapter = Repository(local_dir="sarcasm_adapter", clone_from="nehalelkaref/sarcasm_adapter")
8
+ aoc3_adapter = Repository(local_dir="aoc3_adapter", clone_from="nehalelkaref/aoc3_adapter")
9
+ aoc4_adapter = Repository(local_dir="aoc4_adapter", clone_from="nehalelkaref/aoc4_adapter")
10
+ fusion_adapter = Repository(local_dir="fusion_adapter", clone_from="nehalelkaref/region_fusion")
11
+
12
+ model = AutoAdapterModel.from_pretrained("UBC-NLP/MARBERT")
13
+
14
+ model.load_adapter("aoc3_adapter", set_active=True, with_head=False)
15
+ model.load_adapter("aoc4_adapter", set_active=True, with_head=False)
16
+ model.load_adapter("sarcasm_adapter", set_active=True, with_head=False)
17
+
18
+ model.load_adapter_fusion("fusion_adapter/aoc(3),aoc(4),sarcasm",with_head=True, set_active=True)
19
+
20
+ pipe = TextClassificationPipeline(tokenizer=tokenizer, model=model)
21
+
22
 
23
  app = Flask(__name__)
24