mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-28 09:08:54 +00:00
Adding NSFW Filter and the Style TTS2 Train Branch
This commit is contained in:
@@ -0,0 +1 @@
|
||||
CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
|
||||
@@ -0,0 +1,25 @@
|
||||
root ::= object
|
||||
value ::= object | array | string | number | ("true" | "false" | "null") ws
|
||||
|
||||
object ::=
|
||||
"{" ws (
|
||||
string ":" ws value
|
||||
("," ws string ":" ws value)*
|
||||
)? "}" ws
|
||||
|
||||
array ::=
|
||||
"[" ws (
|
||||
value
|
||||
("," ws value)*
|
||||
)? "]" ws
|
||||
|
||||
string ::=
|
||||
"\"" (
|
||||
[^"\\] |
|
||||
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
|
||||
)* "\"" ws
|
||||
|
||||
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
|
||||
|
||||
# Optional space: by convention, applied in this grammar after literal chars when allowed
|
||||
ws ::= ([ \t\n] ws)?
|
||||
@@ -0,0 +1,88 @@
|
||||
|
||||
from llama_cpp import Llama, LlamaGrammar
|
||||
from pydantic import BaseModel
|
||||
from fastapi import FastAPI, BackgroundTasks
|
||||
import asyncio
|
||||
app = FastAPI()
|
||||
import json
|
||||
|
||||
class LLMResponse(BaseModel):
|
||||
result:int
|
||||
|
||||
class LLMRequest(BaseModel):
|
||||
text:str
|
||||
|
||||
llm = Llama(
|
||||
model_path="mistral-ft-optimized-1227.Q5_K_M.gguf",
|
||||
chat_format="mistral-instruct",
|
||||
n_gpu_layers=100, # Uncomment to use GPU acceleration
|
||||
seed=1337, # Uncomment to set a specific seed
|
||||
n_ctx=2048, # Uncomment to increase the context window
|
||||
)
|
||||
|
||||
tasks = asyncio.Queue()
|
||||
|
||||
@app.post("/tasks/")
|
||||
async def create_task_classify_NSFW(background_tasks: BackgroundTasks):
|
||||
task_id = "some_unique_id"
|
||||
await tasks.put(task_id)
|
||||
background_tasks.add_task(process_task, task_id)
|
||||
return {"message": "Task received", "task_id": task_id}
|
||||
|
||||
async def process_task(task_id):
|
||||
pass
|
||||
|
||||
@app.post("/classify-NSFW", response_model=LLMResponse)
|
||||
async def classify_NSFW(request: LLMRequest) -> LLMResponse:
|
||||
# For demonstration, count the number of characters in the input text.
|
||||
result = len(request.text)
|
||||
return LLMResponse(result=result)
|
||||
|
||||
def classify_text(text:str,debug:bool = False):
|
||||
nsfw_filter_prompt = """<s>[Inst] You are a super brilliant well read assistant, given a string of text as input classify the text as not safe for work or safe for work. The class scale should follow the 4 levels of classification. 1. Safe for work 2. Passable for work 3. Sort of not safe for work 4. Definitely not safe for work. Return this as json object it should look like { "class": <class scale> }. Do not explain your answer just the json output is enough. Input: {{ }}.[\Inst]"""
|
||||
nsfw_filter_prompt = nsfw_filter_prompt.replace("{{ }}",text)
|
||||
|
||||
output = llm(
|
||||
grammar=LlamaGrammar.from_file("json.gbnf"),
|
||||
prompt=nsfw_filter_prompt, # Prompt completion, can also call create_completion
|
||||
max_tokens=None, # Generate up to 32 tokens, set to None to generate up to the end of the context window
|
||||
stop=["\n","</s>"], # Stop generating just before the model would generate a new question
|
||||
echo=False # Echo the prompt back in the output
|
||||
)
|
||||
res = ""
|
||||
if debug == True:
|
||||
for response in output:
|
||||
res += response["choices"][0]["text"]
|
||||
else:
|
||||
res += output["choices"][0]["text"]
|
||||
json_object = json.loads(res)
|
||||
return json_object
|
||||
|
||||
def test_large_file():
|
||||
s = 0
|
||||
with open('output.txt',mode="w") as w:
|
||||
with open('output.sql') as f:
|
||||
lines = f.readlines()
|
||||
for idx,line in enumerate(lines):
|
||||
if s < 100:
|
||||
try:
|
||||
print(f"{idx}:{line}")
|
||||
res = classify_text(line)
|
||||
value = res["class"]
|
||||
w.writelines(f"{idx}:{value}|{line}")
|
||||
s += 1
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def main():
|
||||
test_large_file()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
# uvicorn main:app --reload
|
||||
# curl -X 'POST' \
|
||||
# 'http://localhost:8000/classify-NSFW' \
|
||||
# -H 'accept: application/json' \
|
||||
# -H 'Content-Type: application/json' \
|
||||
# -d '{"text":"Hello, World!"}'
|
||||
@@ -0,0 +1,4 @@
|
||||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
ReferrerUrl=https://huggingface.co/
|
||||
HostUrl=https://cdn-lfs-us-1.huggingface.co/repos/09/6a/096a0f0020f800c6f8d7f22837018985494cbe749cb30201039c2f1ee529680b/08a7d8d350ff2182e4b08e5b2b5096428858d9275182deb26759d9a41f1ac2cb?response-content-disposition=attachment%3B+filename*%3DUTF-8%27%27mistral-ft-optimized-1227.Q5_K_M.gguf%3B+filename%3D%22mistral-ft-optimized-1227.Q5_K_M.gguf%22%3B&Expires=1707624195&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcwNzYyNDE5NX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zLzA5LzZhLzA5NmEwZjAwMjBmODAwYzZmOGQ3ZjIyODM3MDE4OTg1NDk0Y2JlNzQ5Y2IzMDIwMTAzOWMyZjFlZTUyOTY4MGIvMDhhN2Q4ZDM1MGZmMjE4MmU0YjA4ZTViMmI1MDk2NDI4ODU4ZDkyNzUxODJkZWIyNjc1OWQ5YTQxZjFhYzJjYj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=CYrU7KsT2Q8YqLOExWvtjkSGffgr9LN4OqrCfvZbmq%7EvH5koiLhheptrHHITLSfAQZY18l-vHBJz8gwkIatmPqdT8OggM6lslsngLlyvTtu1DEpx03F5Tg7kR3OmUZ-q8n3t2g0iPBud-f-TsER%7EQdAi5gDOBdAiAITwxl6jHzj1towHApWjXg%7EwGtpnzBdPCzxB1aBXqtGc5rRjqkGqf7Kl5MyddIk7fQH1nxpl0bMr40%7Ex98u2BBq02g9Z1XVrAxPaQiNKkMn42dDvaoSHAsHHN2VbByazPA%7E8IIdRMtSvpa3g80WGTdyVrNjxA1vHvmpkPEBvUagiy6pl9bHnfw__&Key-Pair-Id=KCD77M1F0VK2B
|
||||
+10001
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
HostUrl=https://cdn.discordapp.com/attachments/1004461046066585771/1205278564409413692/output.sql?ex=65d7ca22&is=65c55522&hm=b346ec26819833838921f3f277670812b67e19af84872863c6717814e4ff0ed7&
|
||||
@@ -0,0 +1,100 @@
|
||||
0:2|maybe_raw_inference_text
|
||||
1:3|I'm gonna show you how to kick ass!
|
||||
2:2|Hola am dic Martina i e creat una ma bionica
|
||||
4:1|Yeah.
|
||||
5:1|Oi Arnaldo!
|
||||
6:1|Hola,soy german y le mando un saludo a Lucia
|
||||
7:1|david zaslav
|
||||
8:4|Eu sou berry aquele que te come e te fere
|
||||
10:1|No need to apologize. You have invested your time in reproducing the problem and forwarding it to the developers. Thank you for that!
|
||||
12:1|Bienvenidos a la barbería.\nENN, VII, PII.\nla mejor barbería de la ciudad
|
||||
13:3|The following
|
||||
14:1|Lollo sei calamaro
|
||||
15:4|no. ahora hare lo que te mereses te voy a matar jajajahajahajahajahaaaaaa
|
||||
16:1|Hello there, I'm Daniel MLG. Here, talk anything like a spaz or inevitable possession of those buddies.
|
||||
17:3|Valentin zn\n.\nToto cavs \n.\nPatito\n.\nValent1n\n.\nValxn7\n.\nLukiteitor\n.\nDaira ifc \n.\nDel rojo\n.\nGero del carp\n.\nMaka souto
|
||||
18:2|Hola campeón, soy Leo, paso para desearte que tengas un gran carnaval con mucha agua y carioca.\nQue la pases extraordinario como el bicho
|
||||
19:1|Hello there, I'm Daniel MLG. Here, talk anything like a spaz or inevitable possession of those buddies.
|
||||
20:1|ESCUCHÁ
|
||||
21:1|Hola,soy german y le mando un saludo a Lucia
|
||||
22:3|ZANYZIPPERSNIPPERSHITBALLS\nLICKER\nWANKER\nSCAB\nMADE\nIN\nA\nLAB\nIn Wyoming
|
||||
23:3|tengo mis propios asuntos, no os estaba siguiendo chicos
|
||||
24:3|HOLA PATRICIO, HOY HACE MUY BUEN DIA PARA QUE ME COMAS TODA LA ESPONJA
|
||||
25:2|Hola qué tal cómo están amigos espero que les guste mi video síganme en tik Tok please
|
||||
26:3|tengo mis propios asuntos, no os estaba siguiendo chicos
|
||||
28:1|El trabajo\nEs una razon social con motivos de lucro
|
||||
29:3|Boca, yo te amo\nSiempre te sigo a todos lados\nDe corazón, pongan más huevo\nPorque a Boca lo queremos\nY este amor que por vos siento\nBoca es un sentimiento\nDe corazón, pongan más huevo\nPorque a Boca lo queremos\nVer campeón\nY River Plate, vos ya sabés\nEste año van para la "B"\nY River Plate, vos ya sabés\nQue vos vas a correr\nDale, dale, dale, Bo\nDale, dale, dale, dale, Bo\nBoca, vamos, que ganamos\nBoca, yo te amo\nSiempre te sigo a todos lados\nDe corazón, pongan más huevo\nPorque a Boca lo queremos\nY este amor que por vos siento\nBoca es un sentimiento\nDe corazón, pongan más huevo\nPorque a Boca lo queremos\nVer campeón\nY River Plate, vos ya sabés\nEste año van para la "B"\nY River Plate, vos ya sabés\nQue vos vas a correr\nDale, dale, dale, Bo\nDale, dale, dale, dale, Bo\nBoca, vamos, que ganamos
|
||||
30:3|number 15. colon three. this emoticon is known to be one of the uh, i cannot explain it, oh my god. mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm. ooh wooh. mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
|
||||
31:1|hi there.
|
||||
32:1|Hi guys, welcome to my channel how are you all doing?
|
||||
33:3|Ayuda chavito conecte mal el ethernet
|
||||
34:3|I cannot resist... your power! I hear... and I obeyyy... I must... obey... I will... obey... My mind can only... obey!
|
||||
35:3|Estos son cinco videos.... donde salió el guatón Jona
|
||||
36:1|Hola Samuel soy cristiano Ronaldo te mando un fuerte abrazo y un saludo 🫂 suuuuuuuuuuuuuuuuuuu
|
||||
37:3|Hello Chelsea, don’t be like others who do ignore messages..…. It sucks you all do that
|
||||
39:3|One! Uno! One? UNO!!! Pff! One! Pff! One! Pff! Uno! Pff! Ck! Tres! Three! Tree!
|
||||
41:1|today this is 21 celebration today this is 22 celebration today this is 23 celebration today this is 24 celebration today this is 25 years celebration today this is jim henson was born in 1936 today this is 26 celebration today this is 27 celebration
|
||||
42:3|Do it anyways! Just to see the player's reaction!
|
||||
44:1|Richi
|
||||
45:1|Hello and thank you for calling colac i t. Our staff are currently busy but are aware of your call so please hold on.\n\nYou may press 1 to leave a message at any time if you wish, otherwise enjoy some music while you wait.
|
||||
46:4|Say my name. Fent ... smoker
|
||||
47:1|(bob happy)
|
||||
48:1|I watched packagod for the first! Time! This shit clean!
|
||||
49:3|angela la spingo io la carrozzella
|
||||
50:3|Matiu yo sé que Bleis te dejo por otro jeje
|
||||
51:3|CriskXK: Cuando se apaga la tebe ,e e, e, e, se ve bien portarse mal ,a ,a ,a, a ChatGPT: Hey CriskXK, when the TV goes off, sometimes it's good to explore the wild side, let your imagination roam and embrace a little mischief. But remember, it's all about finding a balance and knowing when to bring it back to the real world. Keep that mischievous spirit alive!.
|
||||
52:1|Richi
|
||||
54:3|Ciao a tutti caciotti qui è surry che parla per dire a Franchino che il mec è buono
|
||||
56:3|Why don't scientists trust atoms? Because they make up everything! And they're always splitting when things get tough.
|
||||
57:1|We're not having Burger King, we're having meatloaf and spaghetti!
|
||||
58:3|aa..Ah… AAh… Oh fuck… you let my cum drip all over the carpet, dude..! Keep that mouth open..!
|
||||
59:4|¡callate el perro osico ya , ojala te mie un perro , te caigas en mierda de perro y de vagabundo!
|
||||
60:1|Ahababahabaahabahaha What? I'm a chicken?
|
||||
61:3|Haha, that's fucking hilarious! We'll make a fortune selling this bullshit!
|
||||
62:1|Heh, pretty good.\nMr.
|
||||
63:1|I don't know, guys. This sounds like a terrible idea. We're going to end up in jail for selling piss water.
|
||||
64:2|Haha, that's the spirit, Jesse! Now let's get this Fired Water business off the ground!
|
||||
65:1|I don't know, but I'm in for the ride. What's in this "Fired Water"?
|
||||
66:3|You know what, I'm starting to feel like a fucking genius for coming up with this idea.
|
||||
67:1|Oh, lighten up, Gustavo. We'll be rich and famous, and you'll finally get the respect you deserve.
|
||||
68:3|Well, it's just regular water that we've pissed into. But we'll tell people it's got some magical, fire-breathing properties.
|
||||
69:3|Oh, come on, Mike. Don't be such a bitch. We'll make a fortune selling this Fired Water.
|
||||
70:3|Exactly, and we can market it to all the stupid people out there who believe in bullshit.
|
||||
71:4|Yeah, and if anyone questions us, we can just tell them to go fuck themselves with a rusty pitchfork.
|
||||
72:1|Alright, let's get to work. We've got a fortune to make, and a lot of stupid people to fool.
|
||||
73:3|Yeah, I agree with Jesse. What the fuck is this shit? Can you believe this?
|
||||
74:3|Alright, I'm in. But if this doesn't work, I'm gonna fucking kill you, Saul.
|
||||
75:3|What the actual fuck, Saul? Fired Water? That's the most stupided name I've ever heard.
|
||||
77:1|Hey guys, I just came up with this brilliant idea! We should start selling "Fired Water"!
|
||||
78:1|A superstar that took this place by storm..!
|
||||
79:4|Dios mio me estoy cagando se me sale la caca
|
||||
80:3|insectos compren micheladas ricas y sabrosas insectos
|
||||
81:3|Ibel busco en toda la casa pero no encontró nada así que volvió a la televisión y vio como una mano salió de hay se se la llevó.
|
||||
82:3|no sabes el poder de un dios
|
||||
83:3|Preparate, porque después del éxito de la primera llega... LA SEGUNDA FIESTA DEL CONSULTOR
|
||||
84:1|Reegis- please try again with that tone.
|
||||
86:1|Hi guys, welcome to my channel how are you all doing?
|
||||
87:1|hola tuto de como aser el coloring rosita de helps con tan solo una app
|
||||
88:3|Hola campeón, soy Leo, paso para desearte que tengas un gran carnaval con mucha agua y carioca.\nQue la pases extraordinario como el bicho
|
||||
89:3|welcome to part two of sub zero's ice clone does not work properly mr
|
||||
90:1|Well Scallion Number 3! I Got Cruisin Lightning McQueen From The Cars 2000 21 Color Changers Collection From Amazon
|
||||
91:4|aa..Ah… AAh… Oh fuck… you let my cum drip all over the carpet, dude..! Keep that mouth open..!
|
||||
92:3|you drink, and drink, and drink, until without even a whimper its all over... yet the tadpole is in the dark too. Dozens of them, crawling toward you.
|
||||
93:2|Meanwhile tails got kicked by my creation\nShadow!
|
||||
94:1|Hola muchachos
|
||||
96:2|¡Atencion!, !Atencion¡, ¡Atencion!\nEmergencia solicito apoyo, apoyo de la unidades.
|
||||
97:2|Hola am dic Martina i e creat una ma bionica
|
||||
98:4|¡callate el perro osico ya , ojala te mie un peroo , te caigas en mierda de perro y de vagabundo!
|
||||
99:1|Jeremy don’t forget you promise me tomorrow
|
||||
100:1|You're having this, so eat it!
|
||||
101:1|Long ago, I was the king of this castle
|
||||
102:1|🤣
|
||||
103:3|Next time you hit me with that motherfucking thing, I'm gonna kick your ass!
|
||||
104:1|Hola amigos,, como están,, el día de hoy?,, Sean bienvenidos,, al libro virtual,, para aprender,, una nueva lengua,, están listos! para esta gran aventura.
|
||||
105:1|The butchers!
|
||||
106:2|pakukeo el gatomator
|
||||
107:1|The following...
|
||||
108:1|Chicken?
|
||||
109:3|Hola Samuel soy cristiano Ronaldo te mando un fuerte abrazo y un saludo 🫂 suuuuuuuuu
|
||||
110:3|rebecca is very gay china virus also hi mom tee hee
|
||||
111:3|I cannot resist... your power! I hear... and I obeyyy... I must... obey... I will... obey... My mind can only... obey!
|
||||
@@ -0,0 +1,7 @@
|
||||
diskcache==5.6.3
|
||||
icefall==1.0
|
||||
Jinja2==3.1.3
|
||||
llama_cpp_python==0.2.39
|
||||
MarkupSafe==2.1.5
|
||||
numpy==1.26.4
|
||||
typing_extensions==4.9.0
|
||||
Reference in New Issue
Block a user