Omnibus commited on
Commit
8d3a4dc
·
verified ·
1 Parent(s): 5f63b81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -56
app.py CHANGED
@@ -25,6 +25,7 @@ agents =[
25
  ]
26
  def generate(prompt, history):
27
  print(f'HISTORY:: {history}')
 
28
  output1={}
29
  seed = random.randint(1,1111111111111111)
30
 
@@ -46,26 +47,7 @@ def generate(prompt, history):
46
  for response in stream:
47
  output += response.token.text
48
  yield [(prompt,output)],output1
49
-
50
- '''
51
- with open('tmp.txt','w') as t:
52
- t.writelines(output)
53
- t.close()
54
- with open('tmp.txt','r') as t:
55
- out_lines = t.readlines()
56
- t.close()
57
-
58
- for i,line in enumerate(out_lines):
59
- print(line)
60
- if "DIFFUSION_PROMPT" in line:
61
- try:
62
- d_prompt = line.split("DIFFUSION_PROMPT:",1)[1].split("MEME_TEXT",1)[0]
63
- print(d_prompt)
64
- except Exception as e:
65
- print(e)
66
- pass
67
- '''
68
- output1=output.replace("\n"," ")
69
  if "PROMPT:" and "MEME_TEXT:" in output1:
70
  print("YES")
71
  prompt_t=output1.split("PROMPT:",1)[1].split("MEME_TEXT:",1)[0].strip()
@@ -89,42 +71,6 @@ def run(inp,model_drop):
89
  out = Image.open(io.BytesIO(r.content))
90
  return out
91
 
92
- def run_OG(inp,model_drop):
93
- prompt=inp['PROMPT']
94
- #if len(inp)>max_prompt:
95
- # inp = condense(inp)
96
- #print(f'history :: {history}')
97
- #prompt=format_prompt(inp,history)
98
- seed = random.randint(1,1111111111111111)
99
- print (seed)
100
- generate_kwargs = dict(
101
- temperature=1.0,
102
- max_new_tokens=1048,
103
- top_p=0.99,
104
- repetition_penalty=1.0,
105
- do_sample=True,
106
- seed=seed,
107
- )
108
- content = GENERATE_PROMPT + prompt
109
- print(content)
110
- stream = client.text_generation(content, **generate_kwargs, stream=True, details=True, return_full_text=False)
111
- resp = ""
112
- for response in stream:
113
- resp += response.token.text
114
-
115
- yield ([(inp,resp)],None)
116
- model=loaded_model[int(model_drop)]
117
- out_img=model(resp)
118
- print(out_img)
119
- url=f'https://omnibus-meme-diffusion.hf.space/file={out_img}'
120
- print(url)
121
- uid = uuid.uuid4()
122
- r = requests.get(url, stream=True)
123
- if r.status_code == 200:
124
- out = Image.open(io.BytesIO(r.content))
125
- yield ([(inp,resp)],out)
126
-
127
-
128
  def run_gpt(in_prompt,history,):
129
  if len(in_prompt)>max_prompt:
130
  in_prompt = condense(in_prompt)
 
25
  ]
26
  def generate(prompt, history):
27
  print(f'HISTORY:: {history}')
28
+ history=[]
29
  output1={}
30
  seed = random.randint(1,1111111111111111)
31
 
 
47
  for response in stream:
48
  output += response.token.text
49
  yield [(prompt,output)],output1
50
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  if "PROMPT:" and "MEME_TEXT:" in output1:
52
  print("YES")
53
  prompt_t=output1.split("PROMPT:",1)[1].split("MEME_TEXT:",1)[0].strip()
 
71
  out = Image.open(io.BytesIO(r.content))
72
  return out
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  def run_gpt(in_prompt,history,):
75
  if len(in_prompt)>max_prompt:
76
  in_prompt = condense(in_prompt)