How to generate svg images using python 'quantstat' library - python-3.x

using quantstat library's report.py module, I am able to successfully generate .html images when I call quanstat.reports.html function, and quanstat.reports.full function to generate .png images for the various graphs, charts, reports.
https://github.com/ranaroussi/quantstats/blob/main/quantstats/reports.py
can someone help me at the earliest how to use the same 'report.py' module or other modules in this 'quantstat' library to generate images in .svg format so that they can be opened in any browser such as google-chrome.
Which files of this library need to be modified or enhanced with python code to successfully generate .svg files ?
following code is generating png images when I am passing file path to 'savefig' in my local. used VS Code as IDE
import quantstats as qs
stock1 = qs.utils.download_returns('XLE', period="1y")
stock2 = qs.utils.download_returns('SPY' , period="1y")
qs.reports.full(stock1, stock2)
how can I get images in .svg format using same qs.reports.full(stock1, stock2) ?

Related

Using PDF file in Keras OCR or PyTesseract - Python, is it possible?

I am using Keras OCR and PyTesseract and was wondering if it is possible to use PDF files as the image input.
If not, does anyone have a suggestion as to how to convert a very massive PDF file into PNG or another acceptable format?
Thank you!
No, as far as I know PyTesseract works only with images. You'll need to convert your pdf to images first.
By "very massive PDF" I'm assuming you mean a pdf with lots of pages. This is not an issue. You can use pdf2image library (see the docs here). The method convert_from_path has an output_folder argument that lets you specify the folder where all your generated images will be saved:
Output directory for the generated files, should be seen more as a
“working directory” than an output folder. The converted images will
be written there to save system memory.
You can later use them one by one instead of your pdf to work with PyTesseract. If you don't assign the returned list of images from convert_from_path you don't risk filling up your memory.
Otherwise, if you are willing to keep everything in memory you can use the returned pages directly, like so:
pages = convert_from_path(pdf_path)
for example, my code :
Python : 3.9
Macos: BigSur
from PIL import Image
from fonctions_images import *
from pdf2image import convert_from_path
path='/Users/yves/documents_1/'
fichier =path+'TOUTOU.pdf'
images = convert_from_path(fichier,500, transparent=True,grayscale=True,poppler_path='/usr/local/Cellar/poppler/21.12.0/bin')
for v in range(0,len(images)):
image=images[v]
image.save(path+"image.png", format="png")
test=path+"image.png"
img = cv2.imread(test) # to store image in memory
img = del_lines(path,img) # to supprime the lines
img = cv2.imread(path+"img_final_bin_1.png")
pytesseract.pytesseract.tesseract_cmd = "/usr/local/bin/tesseract"
d=pytesseract.image_to_data(img[3820:4050,2340:4000], lang='fra',config=custom_config,output_type='data.frame')

Is there a way to use sklearn.datasets.load_files for image files

Trying to use custom folders with images instead of X, y = sklearn.datasets.load_digits(return_X_y=True) for sklearn image classification tasks.
load_files does what I need, but it seems to be created for text files. Any tips for working with image files, would be appreciated.
I have the image files stored in following structure
DataSet/label1/image1.png
DataSet/label1/image2.png
DataSet/label1/image3.png
DataSet/label2/image1.png
DataSet/label2/image2.png
I had the same task and found this thread: Using sklearn load_files() to load images from png as data
Hopefully, this helps you too.

how to convert IFC file to Png with Node.js

I tried to find a way to convert IFC file to PNG by his layers. The only ways that I have found are by java or c# that are not working.
Does someone dicover a way to convert it by js or python?

How can i download converted svf or other(ifc) file from autodesk-forge

We are converted rvt file to svf and opened it on autodesk forge viewer. And now we want to download this converted sfv file. How we can do this??
This is my code for converting
enter image description here
Here's a few samples to get you started:
https://forge.autodesk.com/blog/forge-svf-extractor-c-net
https://forge.autodesk.com/blog/forge-svf-extractor-nodejs
https://github.com/cyrillef/extract.autodesk.io
Basically you will need to parse the [manifest](GET :urn/manifest/:derivativeUrn) and follow the paths to download the resources via [GET :urn/manifest/:derivativeUrn](GET :urn/manifest/:derivativeUrn)

Why is bodymovin exporting PNG's and not SVG's?

I'm trying to use lottie to animate an SVG animation created in After Effects. I use the bodymovin extension to export the JSON data file. But, I also noticed the export includes some PNG images. I'm also getting console errors that said PNG's can not be found.
Why is it exporting PNGs as I'm using SVG (an AI file) in AE. Below is my code, and the error.
index.ts
import * as lottie from 'lottie-web';
import * as header from './assets/header.json';
import './css/base.sss';
var animation = lottie.loadAnimation({
container: document.getElementById('header'),
animationData: header,
renderer: 'svg/canvas/html',
autoplay: true
});
But I'm getting the following errors that the images can't be found. Why is bodymovin exporting/looking for pngs? I require SVG's.
Chrome console errors (sorry can't embed until 10 rep)
I found the problem. I have to convert paths to shapes in AI as noted here.
In Adobe After effect, you can use Create Shapes from vector layer
Another way I found was to search the exported .json file for the .png extension and replace the found extensions with .svg. Making sure to add the .svg files to the same directory.
I used this bodymovin render option:
I did my search in the .json file in Dreamweaver like so:
I hope this helps someone!!!

Resources