sophiamyang
commited on
Commit
•
0e8d01c
1
Parent(s):
3129503
update random url function
Browse files
app.py
CHANGED
@@ -6,14 +6,10 @@ from PIL import Image
|
|
6 |
from transformers import CLIPProcessor, CLIPModel
|
7 |
from typing import List, Tuple
|
8 |
|
9 |
-
pn.extension("texteditor", sizing_mode="stretch_width")
|
10 |
-
|
11 |
|
12 |
def set_random_url(_):
|
13 |
-
|
14 |
-
|
15 |
-
else:
|
16 |
-
api_url = "https://api.thedogapi.com/v1/images/search"
|
17 |
with requests.get(api_url) as resp:
|
18 |
resp.raise_for_status()
|
19 |
url = resp.json()[0]["url"]
|
|
|
6 |
from transformers import CLIPProcessor, CLIPModel
|
7 |
from typing import List, Tuple
|
8 |
|
|
|
|
|
9 |
|
10 |
def set_random_url(_):
|
11 |
+
pet = random.choice(["cat", "dog"])
|
12 |
+
api_url = f"https://api.the{pet}api.com/v1/images/search"
|
|
|
|
|
13 |
with requests.get(api_url) as resp:
|
14 |
resp.raise_for_status()
|
15 |
url = resp.json()[0]["url"]
|