Araeynn commited on
Commit
1c3ba4d
·
verified ·
1 Parent(s): 0b0f82e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -15,16 +15,6 @@ import streamlit as st
15
  from huggingface_hub import AsyncInferenceClient, login
16
  import time
17
  import os
18
- from gradio_client import Client
19
-
20
- async def C(x):
21
- c = Client(src="ybelkada/llava-1-5-dlai")
22
- print(c.view_api(return_format="dict"))
23
- result = c.predict(
24
- "Make a detailed description of the image. This would be sufficient for an LLM to answer questions about it with just your answer.",
25
- "ip.png",
26
- api_name="/predict"
27
- )
28
 
29
  launch_time = datetime.datetime.utcnow()
30
 
@@ -94,6 +84,7 @@ PT = AsyncInferenceClient(model=proteus)
94
  LLM = AsyncInferenceClient(model="openchat/openchat-3.5-0106")
95
  RF = AsyncInferenceClient(model="stabilityai/stable-diffusion-xl-refiner-1.0")
96
  UP = AsyncInferenceClient(model="radames/stable-diffusion-x4-upscaler-img2img")
 
97
 
98
 
99
  def ec(x, fd="<|image|>", sd="<|image|>"):
@@ -392,7 +383,8 @@ async def on_message(message):
392
  Use relatively short prompts for images(20 words max), but still put details.
393
  Do not generate images unless the user speciifes that they want an image.
394
  If a user has [bot] next to their username, they are a bot.
395
- If there is ImageParsed stuff at the end of the message, that is the text relative to the image."""
 
396
  try:
397
  os.mkdir("data/" + guild_name)
398
  except:
@@ -402,7 +394,7 @@ async def on_message(message):
402
  message.content = f"[Replied to: ({str(message.reference.cached_message.author)}: {message.reference.cached_message.content})]; {message.content}"
403
  if len(message.attachments) > 0:
404
  await message.attachments[0].save('ip.png')
405
- caption = f"(ImageParsed:[{await C('ip.png')}])"
406
  if os.path.exists(f"data/{guild_name}/{msgchannel_name}"):
407
  with open(f"data/{guild_name}/{msgchannel_name}", "a") as f:
408
  n = "\n"
 
15
  from huggingface_hub import AsyncInferenceClient, login
16
  import time
17
  import os
 
 
 
 
 
 
 
 
 
 
18
 
19
  launch_time = datetime.datetime.utcnow()
20
 
 
84
  LLM = AsyncInferenceClient(model="openchat/openchat-3.5-0106")
85
  RF = AsyncInferenceClient(model="stabilityai/stable-diffusion-xl-refiner-1.0")
86
  UP = AsyncInferenceClient(model="radames/stable-diffusion-x4-upscaler-img2img")
87
+ IC = AsyncInferenceClient(model="Salesforce/blip-image-captioning-large")
88
 
89
 
90
  def ec(x, fd="<|image|>", sd="<|image|>"):
 
383
  Use relatively short prompts for images(20 words max), but still put details.
384
  Do not generate images unless the user speciifes that they want an image.
385
  If a user has [bot] next to their username, they are a bot.
386
+ If there is ImageParsed stuff at the end of the message, that is the text relative to the image.
387
+ If there is (Replied:[]) stuff at the start of the message, that is the message the user replied to."""
388
  try:
389
  os.mkdir("data/" + guild_name)
390
  except:
 
394
  message.content = f"[Replied to: ({str(message.reference.cached_message.author)}: {message.reference.cached_message.content})]; {message.content}"
395
  if len(message.attachments) > 0:
396
  await message.attachments[0].save('ip.png')
397
+ caption = f"(ImageParsed:[{await IC.image_to_text('ip.png')}])"
398
  if os.path.exists(f"data/{guild_name}/{msgchannel_name}"):
399
  with open(f"data/{guild_name}/{msgchannel_name}", "a") as f:
400
  n = "\n"