Omnibus commited on
Commit
0b495bc
·
verified ·
1 Parent(s): 3951a19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -16,6 +16,7 @@ from pypdf import PdfReader
16
  import uuid
17
  #from query import tasks
18
  from gradio_client import Client
 
19
 
20
  from agent import (
21
  PREFIX,
@@ -542,7 +543,10 @@ def clear_fn():
542
  return "",[(None,None)]
543
 
544
  def create_image(url):
545
- #source = requests.get(url)
 
 
 
546
  #source = urllib.request.urlopen(url).read()
547
  #soup = bs4.BeautifulSoup(source.content,'lxml')
548
 
@@ -560,7 +564,9 @@ def create_image(url):
560
  #out.append(p.string)
561
  with open("tmp.svg","w") as svg:
562
  svg.write(url)
563
- return "tmp.svg"
 
 
564
 
565
  score_js="""
566
  function(text_input) {
 
16
  import uuid
17
  #from query import tasks
18
  from gradio_client import Client
19
+ import cairosvg
20
 
21
  from agent import (
22
  PREFIX,
 
543
  return "",[(None,None)]
544
 
545
  def create_image(url):
546
+ '''cairosvg.svg2png(
547
+ url="/path/to/input.svg", write_to="/tmp/output.png")'''
548
+ output = cairosvg.svg2png(
549
+ bytestring=open("/path/to/input.svg").read().encode('utf-8')) #source = requests.get(url)
550
  #source = urllib.request.urlopen(url).read()
551
  #soup = bs4.BeautifulSoup(source.content,'lxml')
552
 
 
564
  #out.append(p.string)
565
  with open("tmp.svg","w") as svg:
566
  svg.write(url)
567
+ output = cairosvg.svg2png(
568
+ bytestring=open(url).read().encode('utf-8'))
569
+ return output
570
 
571
  score_js="""
572
  function(text_input) {