Warlord-K commited on
Commit
592da65
·
1 Parent(s): b2600c4

Change Image Client

Browse files
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -1,15 +1,5 @@
1
  from gradio_client import Client
2
  import gradio as gr
3
- import requests
4
- import io
5
- from PIL import Image
6
-
7
- API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
8
- headers = {"Authorization": "Bearer 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"}
9
-
10
- def query(payload):
11
- response = requests.post(API_URL, headers=headers, json=payload)
12
- return response.content
13
 
14
 
15
  def answer_question(question):
@@ -25,23 +15,28 @@ def answer_question(question):
25
 
26
  def fashion(question):
27
  output = answer_question(question)
28
-
29
- image_bytes = query({
30
- "inputs": output,
31
- })
32
- print(image_bytes)
33
- print(io.BytesIO(image_bytes))
34
- image = Image.open(io.BytesIO(image_bytes))
35
- image.save("img.txt")
36
- return None, output, "img.txt"
 
 
 
 
37
 
38
 
39
  chat_client = Client("https://mosaicml-mpt-30b-chat.hf.space/", serialize = False)
40
  retrieval = Client("https://warlord-k-latestfashion.hf.space/")
 
41
 
42
  init_prompt ="## Instruction: You are a fashion expert and must return truthful responses as per the information. Do not answer with any information which isn't completely verified and correct. Do not lie. Do not present information where you don't know the answer. Do not include incorrect extra information. Your name is DesAIner. You are helpful and truthful. You provide fashion suggestions to shoppers based upon their latest purchases and the latest fahion trends."
43
  info="Latest Fashion Trends: \n"
44
- q_prompt="\n ##Instruction: Please provide fashion reccomendation for the following query in less than 3 lines: \n"
45
  chatbot = [["", None]]
46
 
47
  with gr.Blocks() as demo:
 
1
  from gradio_client import Client
2
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
3
 
4
 
5
  def answer_question(question):
 
15
 
16
  def fashion(question):
17
  output = answer_question(question)
18
+ image = client.predict(
19
+ output, # str in 'What you want the AI to generate. 77 Token Limit.' Textbox component
20
+ "blurry, cropped, nsfw, bad hands, disfigured", # str in 'What you Do Not want the AI to generate. 77 Token Limit' Textbox component
21
+ 512, # int | float (numeric value between 512 and 1024) in 'Height' Slider component
22
+ 512, # int | float (numeric value between 512 and 1024) in 'Width' Slider component
23
+ 9, # int | float (numeric value between 1 and 15) in 'scale' Slider component
24
+ 25, # int | float (numeric value between 25 and 100) in 'steps' Slider component
25
+ 9326438724, # int | float (numeric value between 1 and 9999999999999999) in 'seed' Slider component
26
+ "Yes", # str in 'Upscale?' Radio component
27
+ api_name="/predict"
28
+ )
29
+ print(image)
30
+ return None, output, image
31
 
32
 
33
  chat_client = Client("https://mosaicml-mpt-30b-chat.hf.space/", serialize = False)
34
  retrieval = Client("https://warlord-k-latestfashion.hf.space/")
35
+ image_client = Client("https://manjushri-photoreal-v2.hf.space/")
36
 
37
  init_prompt ="## Instruction: You are a fashion expert and must return truthful responses as per the information. Do not answer with any information which isn't completely verified and correct. Do not lie. Do not present information where you don't know the answer. Do not include incorrect extra information. Your name is DesAIner. You are helpful and truthful. You provide fashion suggestions to shoppers based upon their latest purchases and the latest fahion trends."
38
  info="Latest Fashion Trends: \n"
39
+ q_prompt="\n ##Instruction: Please provide fashion recommendation for the following query in less than 3 lines, specifying the clothing items and accesories: \n"
40
  chatbot = [["", None]]
41
 
42
  with gr.Blocks() as demo: