immunobiotech commited on
Commit
638afb7
Β·
verified Β·
1 Parent(s): d9d6958

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -11,7 +11,7 @@ def search_artworks(query, is_public_domain=False):
11
  search_url = f"{BASE_URL}/artworks/search"
12
  params = {
13
  "q": query,
14
- "limit": 10,
15
  "fields": "id,title,artist_display,date_display,image_id,is_public_domain",
16
  }
17
 
@@ -31,12 +31,13 @@ def search_artworks(query, is_public_domain=False):
31
 
32
  for artwork in results["data"]:
33
  if artwork.get("image_id"):
34
- image_url = f"https://www.artic.edu/iiif/2/{artwork['image_id']}/full/843,/0/default.jpg"
 
35
 
36
  artwork_info = f"""Title: {artwork.get('title', 'Unknown')}\nArtist: {artwork.get('artist_display', 'Unknown')}\nDate: {artwork.get('date_display', 'Unknown')}"""
37
 
38
  try:
39
- img_response = requests.get(image_url, timeout=5)
40
  img_response.raise_for_status()
41
 
42
  img = Image.open(io.BytesIO(img_response.content))
@@ -72,6 +73,8 @@ custom_css = """
72
  border: none !important;
73
  color: white !important;
74
  font-weight: bold !important;
 
 
75
  }
76
  .gr-button:hover {
77
  background: linear-gradient(to right, #4b134f, #c94b4b) !important;
@@ -82,6 +85,7 @@ custom_css = """
82
  border: 2px solid #4b134f !important;
83
  background: rgba(255, 255, 255, 0.1) !important;
84
  color: white !important;
 
85
  }
86
  .gr-form {
87
  background: rgba(0, 0, 0, 0.2) !important;
@@ -95,7 +99,8 @@ custom_css = """
95
  .gr-gallery {
96
  background: rgba(0, 0, 0, 0.3) !important;
97
  border-radius: 15px !important;
98
- padding: 10px !important;
 
99
  }
100
  .title-text {
101
  text-align: center !important;
@@ -111,6 +116,10 @@ custom_css = """
111
  margin-bottom: 2em !important;
112
  font-style: italic !important;
113
  }
 
 
 
 
114
  """
115
 
116
  # Gradio interface
@@ -123,15 +132,17 @@ with gr.Blocks(css=custom_css) as demo:
123
  )
124
 
125
  with gr.Row():
126
- with gr.Column():
127
  search_input = gr.Textbox(
128
  label="Enter your search term",
129
  placeholder="e.g., Monet, Impressionism, landscape...",
130
  )
 
131
  public_domain = gr.Checkbox(
132
  label="Show only public domain artworks",
133
  value=False
134
  )
 
135
  search_btn = gr.Button(
136
  "πŸ” Search",
137
  variant="primary"
@@ -142,9 +153,9 @@ with gr.Blocks(css=custom_css) as demo:
142
  label="Search Results",
143
  show_label=True,
144
  elem_id="gallery",
145
- columns=[2],
146
- rows=[2],
147
- height="500px",
148
  object_fit="contain"
149
  )
150
 
 
11
  search_url = f"{BASE_URL}/artworks/search"
12
  params = {
13
  "q": query,
14
+ "limit": 12, # 더 λ§Žμ€ κ²°κ³Ό ν‘œμ‹œ
15
  "fields": "id,title,artist_display,date_display,image_id,is_public_domain",
16
  }
17
 
 
31
 
32
  for artwork in results["data"]:
33
  if artwork.get("image_id"):
34
+ # 더 큰 이미지 μ‚¬μ΄μ¦ˆλ‘œ λ³€κ²½ (843 -> 1686)
35
+ image_url = f"https://www.artic.edu/iiif/2/{artwork['image_id']}/full/1686,/0/default.jpg"
36
 
37
  artwork_info = f"""Title: {artwork.get('title', 'Unknown')}\nArtist: {artwork.get('artist_display', 'Unknown')}\nDate: {artwork.get('date_display', 'Unknown')}"""
38
 
39
  try:
40
+ img_response = requests.get(image_url, timeout=10) # νƒ€μž„μ•„μ›ƒ 증가
41
  img_response.raise_for_status()
42
 
43
  img = Image.open(io.BytesIO(img_response.content))
 
73
  border: none !important;
74
  color: white !important;
75
  font-weight: bold !important;
76
+ padding: 10px 20px !important;
77
+ font-size: 1.1em !important;
78
  }
79
  .gr-button:hover {
80
  background: linear-gradient(to right, #4b134f, #c94b4b) !important;
 
85
  border: 2px solid #4b134f !important;
86
  background: rgba(255, 255, 255, 0.1) !important;
87
  color: white !important;
88
+ font-size: 1.1em !important;
89
  }
90
  .gr-form {
91
  background: rgba(0, 0, 0, 0.2) !important;
 
99
  .gr-gallery {
100
  background: rgba(0, 0, 0, 0.3) !important;
101
  border-radius: 15px !important;
102
+ padding: 20px !important;
103
+ min-height: 800px !important; /* 가러리 높이 증가 */
104
  }
105
  .title-text {
106
  text-align: center !important;
 
116
  margin-bottom: 2em !important;
117
  font-style: italic !important;
118
  }
119
+ .gallery-image {
120
+ min-height: 400px !important; /* κ°œλ³„ 이미지 μ΅œμ†Œ 높이 μ„€μ • */
121
+ object-fit: contain !important;
122
+ }
123
  """
124
 
125
  # Gradio interface
 
132
  )
133
 
134
  with gr.Row():
135
+ with gr.Column(scale=4):
136
  search_input = gr.Textbox(
137
  label="Enter your search term",
138
  placeholder="e.g., Monet, Impressionism, landscape...",
139
  )
140
+ with gr.Column(scale=1):
141
  public_domain = gr.Checkbox(
142
  label="Show only public domain artworks",
143
  value=False
144
  )
145
+ with gr.Column(scale=1):
146
  search_btn = gr.Button(
147
  "πŸ” Search",
148
  variant="primary"
 
153
  label="Search Results",
154
  show_label=True,
155
  elem_id="gallery",
156
+ columns=3, # μ—΄ 수 증가
157
+ rows=4, # ν–‰ 수 증가
158
+ height="800px", # 가러리 높이 증가
159
  object_fit="contain"
160
  )
161